Well, the most I can do without much effort is have you put the colors in quotes.
colorPrint('lightBlue', 'This is light blue, ', 'yellow', 'and this is yellow.')
Here's the new function.
local function colorPrint(...)
for i=1, #arg do
if i%2 == 1 then
term.setTextColor(arg[i])
else
write(arg[i])
end
end
print() -- this is a print function, so it needs a new line.
end
However it REQUIRES that every odd argument is a color name. So you can't do this:
colorPrint('Some text', 'red', 'lightBlue')
You could also use the first function, while basically redefining every color as a global variable
local lightBlue = colors.lightBlue
local red = colors.red
local yellow = colors.yellow
or do the above using _G
for i, v in pairs(colors) do
if type(v) == 'number' then
_G[v] = v
end
end
But I'm definitely overthinking this ahahaha