Lua has a peculiar block syntax for multi-line strings. It looks like this:
game_backstory = [[ Once upon a time, the wind was blowing, kicking the sea up, nice and wavy. The tide swept in, a darkness came, and everyone drowned in sweet gravy. ]] |
Unfortunately, this makes Pico-8's code editor freak out and try to parse the entire string as individual numbers and words and stuff, grossly aggravating the token count. Plus I can't type \n in the pico-8 editor, despite the character being available in the font.
I'm already using both, since \n makes a great delimiter for writing human-readable data.
There was also a multi-line comment syntax based on it, where you could write
--[[ comments on multiple lines ]] |
but it doesn't seem to work anymore at all, either? :(
Relatedly!
Syntax highlighting is also broken for strings that look like this:
multi_line_string = " what are you doing. that isn't how it works. stop that. " |
It counts the entire area as a string, even though the Lua interpreter only reads it as a syntax error. (You can't have quote strings spanning multiple lines.)
Because of this, I am currently able to get around the problem by combining the two errors:
self_correcting = sub([[" why am i here floating adrift in this sea of gravy? i can't remember what happened to me the night before last. "]],3,-2) |
This still has a significant token penalty, but it's less than what it would be if every word or line of the string were counted against me as a token.
... But if you were to try and print(self_correcting) (on Windows, at least), the console-like behavior would not know how to handle the newlines correctly, doubling-up on newlines and then placing the caret in the space between the first and second lines. X_x; Wow.
This is still a problem in 0.1.6
The comment syntax was fixed, so
--[[ multi-line comments ]] |
works now, but multi-line strings still expect
this = " is not how multi-line strings work. " |
(which is bad)
It should work like this:
this = [[ is actually a multi-line string in Lua. ]] |
[Please log in to post a comment]