This is a pretty simple question. Is there a way to write multi-line strings in a script?
I have some weapon descriptions that I am storing as strings in a module script, and I’d like to be able to read them without having to scroll horizontally.
This is a pretty simple question. Is there a way to write multi-line strings in a script?
I have some weapon descriptions that I am storing as strings in a module script, and I’d like to be able to read them without having to scroll horizontally.
Yep, all you need to do is add \n
to create a new line.
For example:
"Hello,\nThis is a string."
You can also use multi-line comments:
[[Hello,
this is a string]]
And ANSCI beat me to it cause of my bad internet connection lol…
The [[
and ]]
pairs are the Lua multiline strings.
local abc = [[test
abc
123
]]
I’m pretty sure that you need to use \n at the end of the first line in order to add another line in a string.
Not 100% sure, though.
Yes, \n will add a newline character to the string itself, but I just need to write long strings across multiple lines for code readability.
Other ways to do it
local str1 = "this is"..
" a test"
print(str1) -- this is a test
local tab = {
"this is",
" a test"
}
print(table.concat(tab, "")) -- this is a test
Ah, gotcha.
At that point it may be better to just do
local test = "testing\n\
123 123\n\
owo"
How do I add a non string in my case I want to add a variable that constructs a link how would I make it so it doesn’t make it the name of the variable the variable content? But I need to be able to continue going down aswell