Log In  


Surprisingly with all the updates PICO-8 has received, it has one gross error in it that took me hours to debug and later find out and break it into the exact components giving the error alone. It was definitely a case of "it's not my fault." Could cause problems later in other carts and programs.

This will not run:

if (key=="(") print"open"

This will also not run:

if (key==")") print"close"

This will run:

if (key=="[") print"open"

Wow. And no-one's discovered this till now ??

1


After correcting the syntax of the if statements (missing 'THEN' and 'END') all of your examples work as expected. Did I miss something?

This:

key = "("

if (key=="(") then 
 print "open"
end

resulted in 'open' being printed.


1

JasonE, Pico-8 normally allows inline "IF" statements to skip "THEN" and "END" tokens, but only if the conditional is enclosed in parentheses.

Presumably it's not properly detecting the parens.

(This is an extension to Lua. standard Lua always requires the "then" and "end" tokens)


I see, my mistake. I did quite a bit of lua programming before coming to Pico-8 and made my assumption based on the error when I ran the OP's code. This is the error I get when running:

key = "("

if (key=="(")
 print "open"
'then' expected near 'print'

All in the name of saving tokens I suppose :)


Yes, JasonE, you missed something. :)

This kind of error should not exist. I knew the solution was to break it to a IF/THEN/END statement. (I'm not that bad a programmer, I hope). I was just surprised to see something so simple create an error.

And no, apLundell, =I= missed something.

I didn't know that LUA required THEN and END for any IF statement ... so the error must go to the nice shortcut ZEP incorporated into PICO that is non-standard with LUA and likely can be easily fixed by said author.

All in all, quite the learning experience.


Lesson to be learned: sometimes lexing is difficult. ;)


1

For a workaround until then, you can use escape character encoding to hide the "unclosed" parentheses from the preprocessor.

"(" -> "\40"
")" -> "\41"

i.e.

key="\40"
if (key=="\40") print("open")


Good solution that, Catatafish. I don't want to convolute my code anymore than it already is though so for now I'll just use IF/THEN/END when comparing character parentheses in a string.


Yo David, If you could, please get on discord. I might require your expertise


Let me see if I can finish the cart I'm working on first. Should be no more than a day now.


1

COMPLETE !
https://www.lexaloffle.com/bbs/?tid=35307

Scrub, I think our ideas are worth sharing.

Pick a new thread in Lexaloffle and I'll join you there to see what I can help you with. We can share our ideas with the rest of the community this way.


Alright, well I have a game I don't want to share yet, mainly just because of it's pure stupidity. And well to keep it a secret I can't go asking for help compressing an image of the main character.


You could use my compressor if you want. Minju your games are usually not very big in code size. Could post the image here (or in fresh thread) and I'll write the code to show you how to embed it easily.


Can I use an example image? Just so my dude isn't shown?
sorry


This is my example image


It needs to be 64x64 or 128x128.
If you can, copy and paste it direct from PICO so you can be certain what you're sending me uses the exact PICO palette and is precisely what you're getting.

:)



[Please log in to post a comment]