Skip to content

Commit 63c9077

Browse files
committed
Better code to define Ink external functions.
1 parent f07854c commit 63c9077

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

blade-engine/src/com/bladecoder/engine/ink/ExternalFunctions.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.bladecoder.engine.model.Scene;
66
import com.bladecoder.engine.model.World;
77
import com.bladecoder.engine.util.EngineLogger;
8-
import com.bladecoder.ink.runtime.Story.ExternalFunction;
8+
import com.bladecoder.ink.runtime.Story.ExternalFunction1;
99

1010
public class ExternalFunctions {
1111

@@ -18,24 +18,22 @@ public void bindExternalFunctions(final World w, InkManager ink) throws Exceptio
1818

1919
this.inkManager = ink;
2020

21-
inkManager.getStory().bindExternalFunction("inInventory", new ExternalFunction() {
21+
inkManager.getStory().bindExternalFunction("inInventory", new ExternalFunction1<String, Boolean>() {
2222

2323
@Override
24-
public Object call(Object[] args) throws Exception {
25-
String actor = args[0].toString();
26-
24+
public Boolean call(String actor) throws Exception {
2725
if (actor.charAt(0) == '>')
2826
actor = actor.substring(1);
2927

3028
return w.getInventory().get(actor) != null;
3129
}
3230
});
3331

34-
inkManager.getStory().bindExternalFunction("getActorState", new ExternalFunction() {
32+
inkManager.getStory().bindExternalFunction("getActorState", new ExternalFunction1<String, String>() {
3533

3634
@Override
37-
public Object call(Object[] args) throws Exception {
38-
SceneActorRef actor = new SceneActorRef(args[0].toString());
35+
public String call(String act) throws Exception {
36+
SceneActorRef actor = new SceneActorRef(act);
3937
final Scene s = actor.getScene(w);
4038

4139
String actorId = actor.getActorId();
@@ -51,11 +49,10 @@ public Object call(Object[] args) throws Exception {
5149
}
5250
});
5351

54-
inkManager.getStory().bindExternalFunction("getSceneState", new ExternalFunction() {
52+
inkManager.getStory().bindExternalFunction("getSceneState", new ExternalFunction1<String, String>() {
5553

5654
@Override
57-
public Object call(Object[] args) throws Exception {
58-
String scene = args[0].toString();
55+
public String call(String scene) throws Exception {
5956
final Scene s = w.getScene(scene);
6057

6158
if (s == null) {

0 commit comments

Comments
 (0)