SetFlag instruction
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user