This is pretty cool… as long as we don't start seeing rainbow text everywhere :P/>/>
There are two forms of this script, function adapted(ran behind code), or file adapted (Being ran in the CraftOS command-line like 'edit <path>') I basically made this just for fun, well, and to make oeed mad of course ;)/>
--[[Function Adapted]]--
local roygbiv = {
colours.red,
colours.orange,
colours.yellow,
colours.lime,
colours.lightBlue,
colours.blue,
colours.purple
}
local function rainbow(text)
local num = 1
for i = 1,#text do
local letter = string.sub(text,i,i)
if num > #roygbiv then num = 1 end
term.setTextColour(roygbiv[num])
term.write(letter)
num = num+1
end
end
--Example:
--rainbow("Rainbow")
Or:
--[[File Adapted]]
local tArgs = {...}
if #tArgs <= 0 then
print("Usage: "..shell.getRunningProgram().." <text>")
return
end
local roygbiv = {
colours.red,
colours.orange,
colours.yellow,
colours.lime,
colours.lightBlue,
colours.blue,
colours.purple
}
local num = 1
for i = 1,#tArgs[1] do
local letter = string.sub(tArgs[1],i,i)
if num > #roygbiv then num = 1 end
term.setTextColour(roygbiv[num])
term.write(letter)
if num == #tArgs[1] then
print("")
end
num = num+1
end
With the commandline version just type:
programName <textToColor>
Pastebin for File Adapted:
a7274dDs
Pastebin for Function Adapted:
Gks7iSKG
Also, you may use this in your Graphical Shells as long as I am given full credit. This code CAN be modified for personal use, but nothing more.