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))
Help with widget "Show build"
Moderator: Moderators
Re: Help with widget "Show build"
Could you please paste the whole error message from the console? It is also stored in infolog.txt.
Re: Help with widget "Show build"
[f=0011495] Error in DrawWorld(): [string "LuaUI\Widgets\unit_showbuild.lua"]:82: bad argument #1 to 'GetTeamColor' (number expected, got no value)Beherith wrote:Could you please paste the whole error message from the console? It is also stored in infolog.txt.
- Attachments
-
- infolog.txt
- (66.42 KiB) Downloaded 110 times
Re: Help with widget "Show build"
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.
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.