Hi! I thought I’d participate in Advent of Code this year. I have all my code for the first challenge laid out, yet I cannot seem to figure out how to import my values into Roblox.
I thought Find All/Replace All might work if I pasted in the values and attempted to add commas on to each line/number, but that didn’t work out.
If someone could please lend me a hand with this, it would be greatly appreciated!
1 Like
Create a new module script, put this in it:
return [[
]]
paste the input in the middle, pray it doesn’t have too many ]'s. Good luck! AoC is lots of fun, wish I had more time to spend on it 
You can just add as many as =
signs between [
and ]
characters you want instead of just praying that [
and ]
characters doesn’t malform the string:
return [===[
]===]
1 Like
Woah cool, thanks!
@op in case you need it, here’s how to split the input into lines and lines into e.g. space-separated values:
local lines = string.split(input, '/n')
...
function lineToNumbers(line)
local ns = {}
for _, word in pairs(string.split(line, ' ')) do end
table.insert(ns, tonumber(word))
end
return ns
end
This is nice, but how am I supposed to loop through it if it’s a string?
inputS = --your input
lines = string.split(inputS, '\n')
for i, line in ipairs(lines) do
--code handling each line
I should add for the advent of code stuff, you will be manipulating strings a lot.
I’d recommend looking at all the methods strings have in luau (Roblox’s lua, which has gained a lot of methods recently): string | Roblox Creator Documentation