Hi, I’m trying to make a modulescript for info on characters. So far it’s been working fine, but I found that when you print a string, it looks like this:

In code:

How would I define strings in a way that can have multiple lines (for readability) that wouldn’t affect the string itself? (Ex. printing out like this:)

1 Like
you could remove every \n
from the string. this would bring them in line again.
local str = [[
Multi
Line
String
]]
local singleLine = string.gsub(str, "\n", "")
print(singleLine) -- Output: MultiLineString
2 Likes
Some strings have their own line breaks though, so I can’t remove \n
entirely.
what about using a custom character that behaves as your \n
like this.
This would make every _
be a new line. you could swap it out to some symbol or a chinese character you will never use in your string so that it doesn’t interfere with the text.
local customLineSplitter = "_"
local str = [[
Multi_
Line_
Hello
World
]]
local singleLine = string.gsub(str, "\n", "")
local customNewLine = string.gsub(singleLine, customLineSplitter, "\n")
print(customNewLine)
--[[
Multi
Line
HelloWorld
]]
3 Likes
That should work fine. Thanks!