Log In  

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.

Cart #16085 | 2015-11-01 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

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.

P#16143 2015-11-02 22:52 ( Edited 2016-05-20 18:16)

Cheers JTE, Fixed for 0.1.4
I added \ to keyboard input too.

P#16171 2015-11-03 12:43 ( Edited 2015-11-03 17:43)

Oh right... >_< I should have noted that the parser doesn't handle escape sequences like \" or \' properly either, I didn't think of it since I generally don't have to use it...

But thanks for the multiline string support! That'll be great.

P#16230 2015-11-04 17:10 ( Edited 2015-11-04 22:10)
1

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.
]]
P#20115 2016-05-02 12:21 ( Edited 2016-05-02 16:21)

fixed for 0.1.7

Also fixed the pre-processor messing with shorthand forms inside multi-line strings.

P#20941 2016-05-20 14:16 ( Edited 2016-05-20 18:16)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-16 14:10:26 | 0.057s | Q:20