SetFlag instruction

This commit is contained in:
Anuken
2022-04-15 12:46:20 -04:00
parent e1e29c1da7
commit f533aae887
2 changed files with 52 additions and 0 deletions

View File

@@ -1519,5 +1519,28 @@ public class LExecutor{
}
}
public static class SetFlagI implements LInstruction{
public int flag, value;
public SetFlagI(int flag, int value){
this.flag = flag;
this.value = value;
}
public SetFlagI(){
}
@Override
public void run(LExecutor exec){
if(exec.obj(flag) instanceof String str){
if(exec.bool(value)){
state.rules.objectiveFlags.remove(str);
}else{
state.rules.objectiveFlags.add(str);
}
}
}
}
//endregion
}

View File

@@ -1543,4 +1543,33 @@ public class LStatements{
return new GetFlagI(builder.var(result), builder.var(flag));
}
}
@RegisterStatement("setflag")
public static class SetFlagStatement extends LStatement{
public String flag = "\"flag\"", value = "true";
@Override
public void build(Table table){
fields(table, flag, str -> flag = str);
table.add(" = ");
fields(table, value, str -> value = str);
}
@Override
public boolean privileged(){
return true;
}
@Override
public Color color(){
return Pal.logicWorld;
}
@Override
public LInstruction build(LAssembler builder){
return new SetFlagI(builder.var(flag), builder.var(value));
}
}
}