Help with widget "Show build"

Help with widget "Show build"

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

Moderator: Moderators

Post Reply
Broker
Posts: 156
Joined: 02 Jul 2012, 13:16

Help with widget "Show build"

Post 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))
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Help with widget "Show build"

Post by Beherith »

Could you please paste the whole error message from the console? It is also stored in infolog.txt.
Broker
Posts: 156
Joined: 02 Jul 2012, 13:16

Re: Help with widget "Show build"

Post 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)
Attachments
infolog.txt
(66.42 KiB) Downloaded 110 times
Broker
Posts: 156
Joined: 02 Jul 2012, 13:16

Re: Help with widget "Show build"

Post 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.
Post Reply

Return to “Lua Scripts”