mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-03-10 17:01:11 -07:00
Revert back to {0}-style format
This commit is contained in:
parent
862d3153d9
commit
de50b207e5
2 changed files with 19 additions and 5 deletions
|
|
@ -2288,7 +2288,7 @@ unit.emanate.description = Builds structures to defend the Acropolis core. Repai
|
|||
lst.read = Read a number from 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.format = Replace next placeholder ("[accent]@[]") in text buffer with a value.\nExample:\n[accent]print "test @"\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.drawflush = Flush queued [accent]Draw[] operations to a display.
|
||||
lst.printflush = Flush queued [accent]Print[] operations to a message block.
|
||||
|
|
|
|||
|
|
@ -1113,7 +1113,21 @@ public class LExecutor{
|
|||
|
||||
if(exec.textBuffer.length() >= maxTextBuffer) return;
|
||||
|
||||
int placeholderIndex = exec.textBuffer.indexOf("@");
|
||||
int placeholderIndex = -1;
|
||||
int placeholderNumber = 10;
|
||||
|
||||
for(int i = 0; i < exec.textBuffer.length(); i++){
|
||||
if(exec.textBuffer.charAt(i) == '{' && exec.textBuffer.length() - i > 2){
|
||||
char numChar = exec.textBuffer.charAt(i + 1);
|
||||
|
||||
if(numChar >= '0' && numChar <= '9' && exec.textBuffer.charAt(i + 2) == '}'){
|
||||
if(numChar - '0' < placeholderNumber){
|
||||
placeholderNumber = numChar - '0';
|
||||
placeholderIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(placeholderIndex == -1) return;
|
||||
|
||||
|
|
@ -1122,13 +1136,13 @@ public class LExecutor{
|
|||
if(v.isobj && value != 0){
|
||||
String strValue = PrintI.toString(v.objval);
|
||||
|
||||
exec.textBuffer.replace(placeholderIndex, placeholderIndex + 1, strValue);
|
||||
exec.textBuffer.replace(placeholderIndex, placeholderIndex + 3, strValue);
|
||||
}else{
|
||||
//display integer version when possible
|
||||
if(Math.abs(v.numval - (long)v.numval) < 0.00001){
|
||||
exec.textBuffer.replace(placeholderIndex, placeholderIndex + 1, (long)v.numval + "");
|
||||
exec.textBuffer.replace(placeholderIndex, placeholderIndex + 3, (long)v.numval + "");
|
||||
}else{
|
||||
exec.textBuffer.replace(placeholderIndex, placeholderIndex + 1, v.numval + "");
|
||||
exec.textBuffer.replace(placeholderIndex, placeholderIndex + 3, v.numval + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue