Stormworks: Build and Rescue

Stormworks: Build and Rescue

Alistair Apr 8, 2021 @ 8:16am
String format in lua
hello everybody,
in python, string formats are written like this:
print('Hi', 'how', 'are', 'you')
So I thought I could use the same with string formats in lua to get two different pieces of text to print using the same line of code:
screen.drawText(14, 56, string.format('%.0f', cntdwnmins, ':'))
In which 'cntdwnmins' is a variable to be printed to the screen, and I would like a colon to be printed after the variable.
however, that doesn't seem to work. The screen turns on without saying anything about a syntax error (or similar), and it prints the variable, but doesn't print the cursor.
What I was wondering was if anyone knew if it would be possible to get a variable to print on screen with a piece of text following immediately after it, using string formats.
forgive me for the probably obvious question, I'm still learning lmao.
Have a good day
< >
Showing 1-2 of 2 comments
GrumpyOldMan Apr 8, 2021 @ 10:22am 
You can add all kinds of characters inside the string in string.format:
screen.drawText(14, 56, string.format('%.0f:', cntdwnmins))
Not sure if you'd want to use %.0f to display minutes though.
Alistair Apr 8, 2021 @ 12:21pm 
thank you very much :)
I wonder why it wasn’t working then, must have been a problem I was doing. Do I put the extra characters inside the same apostrophes as %.0f then?
< >
Showing 1-2 of 2 comments
Per page: 1530 50

Date Posted: Apr 8, 2021 @ 8:16am
Posts: 2