I believe what Briarfox is looking for is a way to colour parts of a text string in Codea, in different colours, like this
Now this may not be what he wants, but I found a way to do it, if anyone is interested. It is difficult because you have to write each piece of different coloured text separately, and line it all up correctly, which is harder if the text is wrapping as well.
You can do this as follows. Assume you have a set of text strings, to be written one after the other, each in a different colour, as in the example above.
What you is write the entire string (ie all the strings joined together) in the colour of the last text string. So in the example above, you write “This is some colored text which is a mixture of different colors”, in black.
Then you write everything except the last string, in the colour of the next to last string. So we write “This is some colored text which is a mixture of different” in green. This overwrites everything except the last word “colors”, leaving it in black.
Then you write everything except the last 2 strings, ie "“This is some colored text which is a mixture of” in white. This leaves “different” in green and “colors” in black.
You work your way back to to the first string like this - the code below demonstrates.
function setup()
--table of text and colours
t={"This is some ","colored ","text ","which is a ","mixture ","of ","different ","colors",}
c={color(0),color(255,0,0),color(0,0,255),color(0),color(255,255,0),color(255),
color(0,255,0),color(0)}
--create a table with combined strings
tt={}
tt[1]=t[1]
for i=2,#t do
tt[i]=tt[i-1]..t[i]
end
end
function draw()
background(150)
textMode(CORNER)
fontSize(24)
textWrapWidth(300)
print(w,h)
textAlign(LEFT)
--write the combined strings starting from the end and working back
for i=#t,1,-1 do
fill(c[i])
--we need to adjust starting height
--because Codea measures from the bottom of the text upwards
local w,h=textSize(tt[i])
text(tt[i],300,400-h)
end
end