Page 1 of 1

Help with widget "Show build"

Posted: 23 Jul 2012, 12:13
by Broker
Hello After upgrade to version 89 I have a problem with the widget Show build. After a while the widget exits with an error on line 82

local r,g,b = Spring.GetTeamColor(Spring.GetUnitTeam(myCmd.uid))

The console shows that the argument GetTeamColor is null.
I need your help or advice to fix the problem.
Here is the entire text of the program to this point.

function widget:DrawWorld()
for key, myCmd in pairs(command) do
local cmd = myCmd.id
local params = myCmd.params
cmd = math.abs( cmd )
local x, y, z, h = params[1], params[2], params[3], params[4]
if(h ~= nil) then
local degrees = h * 90
if Spring.IsAABBInView(x-1,y-1,z-1,x+1,y+1,z+1) then
local r,g,b = Spring.GetTeamColor(Spring.GetUnitTeam(myCmd.uid))

Re: Help with widget "Show build"

Posted: 23 Jul 2012, 13:45
by Beherith
Could you please paste the whole error message from the console? It is also stored in infolog.txt.

Re: Help with widget "Show build"

Posted: 23 Jul 2012, 16:55
by Broker
Beherith wrote:Could you please paste the whole error message from the console? It is also stored in infolog.txt.
[f=0011495] Error in DrawWorld(): [string "LuaUI\Widgets\unit_showbuild.lua"]:82: bad argument #1 to 'GetTeamColor' (number expected, got no value)

Re: Help with widget "Show build"

Posted: 25 Jul 2012, 14:35
by Broker
I’ve solved the problem by adding the line:

if (Spring.GetUnitTeam(myCmd.uid) ~= nil) then

after the start of the cycle. The Widget now does not fail but I have an unexpected effect. There are unfinished objects left on the map without any constructors assigned to construct them.