* Added PrintChar operation

* Added 1ue999 to contributors

* Added PrintChar description, and improved the design of it.

* Ok intellij, removing the int cast

* Added capability to print content icons (@flare or @router)
https://github.com/Anuken/Mindustry/pull/10451#discussion_r1941282280

* Formatting changes (hopefully all of them)

* Update core/src/mindustry/logic/LStatements.java

* Update core/src/mindustry/logic/LStatements.java

---------

Co-authored-by: Anuken <arnukren@gmail.com>
This commit is contained in:
1ue999
2025-02-05 01:39:33 +01:00
committed by GitHub
parent fbd2944663
commit c4e25e312f
4 changed files with 65 additions and 0 deletions

View File

@@ -2415,6 +2415,7 @@ unit.emanate.description = Builds structures to defend the Acropolis core. Repai
lst.read = Read a number from a linked memory cell. lst.read = Read a number from a linked memory cell.
lst.write = Write a number to a linked memory cell. lst.write = Write a number to a linked memory cell.
lst.print = Add text to the print buffer.\nDoes not display anything until [accent]Print Flush[] is used. lst.print = Add text to the print buffer.\nDoes not display anything until [accent]Print Flush[] is used.
lst.printchar = Add a UTF-16 character or content icon to the print buffer.\nDoes not display anything until [accent]Print Flush[] is used.
lst.format = Replace next placeholder in text buffer with a value.\nDoes not do anything if placeholder pattern is invalid.\nPlaceholder pattern: "{[accent]number 0-9[]}"\nExample:\n[accent]print "test {0}"\nformat "example" lst.format = Replace next placeholder in text buffer with a value.\nDoes not do anything if placeholder pattern is invalid.\nPlaceholder pattern: "{[accent]number 0-9[]}"\nExample:\n[accent]print "test {0}"\nformat "example"
lst.draw = Add an operation to the drawing buffer.\nDoes not display anything until [accent]Draw Flush[] is used. lst.draw = Add an operation to the drawing buffer.\nDoes not display anything until [accent]Draw Flush[] is used.
lst.drawflush = Flush queued [accent]Draw[] operations to a display. lst.drawflush = Flush queued [accent]Draw[] operations to a display.

View File

@@ -171,3 +171,4 @@ hexagon-recursion
JasonP01 JasonP01
BlueTheCube BlueTheCube
sasha0552 sasha0552
1ue999

View File

@@ -988,6 +988,29 @@ public class LExecutor{
} }
} }
public static class PrintCharI implements LInstruction{
public LVar value;
public PrintCharI(LVar value){
this.value = value;
}
PrintCharI(){}
@Override
public void run(LExecutor exec){
if(exec.textBuffer.length() >= maxTextBuffer) return;
if(value.isobj){
if(!(value.objval instanceof UnlockableContent cont)) return;
exec.textBuffer.append((char)cont.emojiChar());
return;
}
exec.textBuffer.append((char)Math.floor(value.numval));
}
}
public static class FormatI implements LInstruction{ public static class FormatI implements LInstruction{
public LVar value; public LVar value;

View File

@@ -312,6 +312,46 @@ public class LStatements{
} }
} }
@RegisterStatement("printchar")
public static class PrintCharStatement extends LStatement{
public String value = "65";
@Override
public void build(Table table){
table.add(" char ");
TextField field = field(table, value, str -> value = str).get();
table.button(b -> {
b.image(Icon.pencilSmall);
b.clicked(() -> showSelectTable(b, (t, hide) -> {
t.row();
t.table(i -> {
i.left();
int c = 0;
for(char j = 32; j < 127; j++){
final int chr = j;
i.button(String.valueOf(j), Styles.flatt, () -> {
value = Integer.toString(chr);
field.setText(value);
hide.run();
}).size(32f);
if(++c % 8 == 0) i.row();
}
});
}));
}, Styles.logict, () -> {}).size(40f).padLeft(-2).color(table.color);
}
@Override
public LInstruction build(LAssembler builder){
return new PrintCharI(builder.var(value));
}
@Override
public LCategory category(){
return LCategory.io;
}
}
@RegisterStatement("format") @RegisterStatement("format")
public static class FormatStatement extends LStatement{ public static class FormatStatement extends LStatement{
public String value = "\"frog\""; public String value = "\"frog\"";