I know this is probably super simple and I’m being dumb right now, but how would I take a string and convert it into a table/array where each entry in the table is a character of the string?
Yeah, I’m using this as a function where I feed in the script’s contents and the lexer can loop over each entry in the table and form phrases for the interpreter to process.
The simplest way I can think of would be to use string.split, which returns a table itself.
The function splits the string wherever a specified expression occurs, so if you use an empty string it will split every character.
local s = "abc 123"
local t = s:split("")
table.foreachi(t, print)
--[[
1 a
2 b
3 c
4
5 1
6 2
7 3
]]--