gl.Text and colors.

gl.Text and colors.

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

gl.Text and colors.

Post by smoth »

I cannot fathom it, in my infoboxoveride code:
http://pastebin.com/YTbgbQ6a
I can specify colors just fine,

however, add:
http://pastebin.com/Ee8atKQC

Which takes a defined color and builds it into a \#\#\#\# type string and I then insert it via:

Code: Select all

colors = VFS.Include("gamedata/colors.lua")

local ExoColor	= tostring(colors["exoColor"].argb)
local RefColor	= tostring(colors["refColor"].argb)
local MatColor	= tostring(colors["matColor"].argb)
it will print the \#\#\#\# instead of coloring my strings. REALLY QUEER. So why is it doing this, do you guys know?
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: gl.Text and colors.

Post by smoth »

so kept getting pissed about this thing and then took a break only to think about how it converts theses \255 etc to characters then I thought about a joke I did to make my code unreadable in my intermediate comp sci class...

using character vars then suddenly I knew what I had to do.
changing my values to a string as though they were ascii chars.
>:3

Code: Select all

for name,vals in pairs(colors) do
	colorSets[name]	= {}
	colorSets[name].argb = string.char(math.floor(vals[4]*255),math.floor(vals[1]*255),
										math.floor(vals[2]*255),math.floor(vals[3]*255))
	colorSets[name].rgba = colors[name]
end
Post Reply

Return to “Lua Scripts”