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?

P#45151 2017-10-12 19:31 ( Edited 2017-10-13 01:06)

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

size="huge"
object="chair"

print("That is a "..size.." green "..object)
P#45152 2017-10-12 19:48 ( Edited 2017-10-12 23:48)

MBoffin

Thanks ^-^

P#45154 2017-10-12 19:59 ( Edited 2017-10-12 23:59)

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.

P#45156 2017-10-12 21:06 ( Edited 2017-10-13 01:06)

can you color the text you print?

P#65081 2019-06-08 19:03

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

P#65083 2019-06-08 20:32

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-19 21:26:29 | 0.007s | Q:19