Logic data instruction (#9935)
* Logic `data` instruction * Rename to `clientdata` & reliable option * frog Co-authored-by: Anuken <arnukren@gmail.com> --------- Co-authored-by: Anuken <arnukren@gmail.com>
This commit is contained in:
@@ -41,6 +41,7 @@ public class LExecutor{
|
||||
maxDisplayBuffer = 1024,
|
||||
maxTextBuffer = 400;
|
||||
|
||||
|
||||
public LInstruction[] instructions = {};
|
||||
/** Non-constant variables used for network sync */
|
||||
public LVar[] vars = {};
|
||||
@@ -1761,6 +1762,31 @@ public class LExecutor{
|
||||
}
|
||||
}
|
||||
|
||||
public static class ClientDataI implements LInstruction{
|
||||
public LVar channel, value, reliable;
|
||||
|
||||
public ClientDataI(LVar channel, LVar value, LVar reliable){
|
||||
this.channel = channel;
|
||||
this.value = value;
|
||||
this.reliable = reliable;
|
||||
}
|
||||
|
||||
public ClientDataI() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(LExecutor exec) {
|
||||
if(channel.obj() instanceof String c){
|
||||
Object v = value.isobj ? value.objval : value.numval;
|
||||
if(reliable.bool()){
|
||||
Call.clientLogicDataReliable(c, v);
|
||||
}else{
|
||||
Call.clientLogicDataUnreliable(c, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class GetFlagI implements LInstruction{
|
||||
public LVar result, flag;
|
||||
|
||||
|
||||
@@ -1911,6 +1911,42 @@ public class LStatements{
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterStatement("clientdata")
|
||||
public static class ClientDataStatement extends LStatement{
|
||||
public String channel = "\"frog\"", value = "\"bar\"", reliable = "0";
|
||||
|
||||
@Override
|
||||
public void build(Table table){
|
||||
table.add("send ");
|
||||
fields(table, value, str -> value = str);
|
||||
table.add(" on ");
|
||||
fields(table, channel, str -> channel = str);
|
||||
table.add(", reliable ");
|
||||
fields(table, channel, str -> channel = str);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hidden(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean privileged(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LInstruction build(LAssembler builder){
|
||||
if(!state.rules.allowLogicData) return null;
|
||||
return new ClientDataI(builder.var(channel), builder.var(value), builder.var(reliable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LCategory category(){
|
||||
return LCategory.world;
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterStatement("getflag")
|
||||
public static class GetFlagStatement extends LStatement{
|
||||
public String result = "result", flag = "\"flag\"";
|
||||
|
||||
Reference in New Issue
Block a user