diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/If.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/If.java index 24d84d35..e6e76504 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/If.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/If.java @@ -40,6 +40,16 @@ public class If implements SpecialCommand { return true; } + if (command[2].equals("exists")) { + if (scriptExecutor.isVariable(command[1])) { + setIndex(scriptExecutor, command[3]); + } else { + if (command.length > 4) { + setIndex(scriptExecutor, command[4]); + } + } + } + Value v1 = scriptExecutor.getOrItselfValue(command[1]); Value v2 = scriptExecutor.getOrItselfValue(command[2]); if (v1.getClass() != v2.getClass()) { @@ -50,10 +60,17 @@ public class If implements SpecialCommand { return true; } if (v1.asString().equals(v2.asString())) { - scriptExecutor.setIndex((int) asLong(command[3])); + setIndex(scriptExecutor, command[3]); } else if (command.length > 4) { - scriptExecutor.setIndex((int) asLong(command[4])); + setIndex(scriptExecutor, command[4]); } return true; } + + private void setIndex(ScriptExecutor scriptExecutor, String name) { + int jp = scriptExecutor.jumpPoints.getOrDefault(name, -1); + if (jp != -1) { + scriptExecutor.setIndex(jp); + } + } }