Code: Select all
local function SetupCommandColors(state)
local alpha = state and 1 or 0
local f = io.open('cmdcolors.tmp', 'w+')
if (f) then
f:write('move 0.5 1.0 0.5 ' .. alpha)
f:close()
Spring.SendCommands({'cmdcolors cmdcolors.tmp'})
end
local f = io.open('cmdcolors.tmp', 'w+')
if (f) then
f:write('unitBox 0 1 0 ' .. alpha)
f:close()
Spring.SendCommands({'cmdcolors cmdcolors.tmp'})
end
os.remove('cmdcolors.tmp')
end
The code above: 'unitBox' gets properly hidden, 'move' wont.
(also: is it possible to just open 'cmdcolors.tmp' just once and write multiple times?)