Logic wait & content look up instructions

This commit is contained in:
Anuken
2021-06-24 15:38:20 -04:00
parent 38a9ad9ec1
commit 0949852758
9 changed files with 192 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import mindustry.*;
import mindustry.annotations.Annotations.*;
import mindustry.ctype.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.logic.LCanvas.*;
@@ -662,8 +663,7 @@ public class LStatements{
}
}
//TODO untested
//@RegisterStatement("wait")
@RegisterStatement("wait")
public static class WaitStatement extends LStatement{
public String value = "0.5";
@@ -684,6 +684,42 @@ public class LStatements{
}
}
@RegisterStatement("lookup")
public static class LookupStatement extends LStatement{
public ContentType type = ContentType.item;
public String result = "result", id = "0";
@Override
public void build(Table table){
fields(table, result, str -> result = str);
table.add(" = lookup ");
row(table);
table.button(b -> {
b.label(() -> type.name());
b.clicked(() -> showSelect(b, GlobalConstants.lookableContent, type, o -> {
type = o;
}));
}, Styles.logict, () -> {}).size(64f, 40f).pad(4f).color(table.color);
table.add(" # ");
fields(table, id, str -> id = str);
}
@Override
public Color color(){
return Pal.logicOperations;
}
@Override
public LInstruction build(LAssembler builder){
return new LookupI(builder.var(result), builder.var(id), type);
}
}
@RegisterStatement("end")
public static class EndStatement extends LStatement{
@Override