Log In  

Lua supports multi-line string literals surrounded with double square brackets:

x = [[hi
there "friend"]]

The square bracket delimiters can include an arbitrary number of equal signs between the brackets as long as the beginning and end delimiters match. Everything between the pair is literally part of the string, including slashes and other things that might look like string delimiters:

x = [===[wat
is [[going]] "on" [====[with this
]====]]===]

This is fully supported by Lua 5.2 and so is fully supported by Pico-8, with two bugs specific to the form with the equal signs:

  • The token counter doesn't support the fancier [=+[ form, so words and symbols in the string get counted as individual tokens.
  • The editor's syntax coloring doesn't support it either.

There are a dozen or so carts posted to the BBS that use multiline strings, though none of them use the fancier [=+[ form.

[Updated 10/23 when I noticed that only the [=+[ form has these issues.]

P#31484 2016-10-22 17:38 ( Edited 2016-10-23 20:07)

dddaaannn, if you are just wanting multi-line strings, you can use:

string=[[
la dee dah ... laaa !
Line 2 of string
]]

Works very effectively.

P#31490 2016-10-22 19:11 ( Edited 2016-10-22 23:11)

dw817, you don't need to reply to every forum post, you know. :) If you read my post you'll see I'm familiar with the multiline string feature. The bug report is about token counting and syntax highlighting of multiline strings with the [=+[ form.

P#31556 2016-10-23 15:40 ( Edited 2016-10-23 20:02)

Sorry, I was reading this:

x = [===[wat
is [[going]] "on" [====[with this
]====]]===]

And it appeared to me like you were having difficulty understanding extended strings. If you don't want my help I won't offer it. Some people are a little like this. My friend, Chris, for instance.

I understand.

As for me ? I can use all the help I can get. And that means (a bit like a teacher would say) there are no wrong answers for me. If you see me asking a question anywhere, PLEASE feel free to jump in both feet with an answer. I will most certainly listen to you each and every time without fail.

You just might make the difference between others not knowing and when they do because of your input !

P#31560 2016-10-23 16:07 ( Edited 2016-10-23 20:45)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-20 12:59:05 | 0.008s | Q:11