Log In  


I was trying out C# and I noticed you can have more that one variable to a print function, I wonder if this can be done on pico-8 / Lua?



You can add strings together using .. in PICO-8. Like this:

size="huge"
object="chair"

print("That is a "..size.." green "..object)

MBoffin

Thanks ^-^


Side note: The first in a series of .. concatenations has to be a string, so if the first item you want to show is a number, you have to put an empty string on the left, e.g.:

a = 1
b = 2
print(""..a.."+"..b.."="..(a + b))

This is actually useful for turning a number into a string:

num = 123
num_str = ""..num

And you can actually do it in reverse, turning a string with a properly-formatted number in it into a real number. You don't concatenate with "", but rather you add the string to zero. Same idea, different type:

num_str = "456"
num = 0 + num_str

Lua's pretty nice about basic conversions.


can you color the text you print?


You sure can, by adding "col", as mentioned here: https://pico-8.fandom.com/wiki/Print
You also need to add the number for the colour you want, which you can look up here: https://pico-8.fandom.com/wiki/Graphics



[Please log in to post a comment]