Page 1 of 1

User widgets with "[GetUnitCommands] called too often" errors

Posted: 10 Oct 2014, 20:36
by Flash
since V98 widget is broken for me

Code: Select all

Error in Update(): [string "LuaUI\Widgets\gui_idle_builders_new.lua"]:59: [GetUnitCommands] called too often without a 2nd argument to define maxNumCmds returned in the table, please check your code!
Especially when you only read the first cmd or want to check if the queue is non-empty, this can be a huge performance leak!

Re: Does anyone use the IdleBuildersNEW widget?

Posted: 10 Oct 2014, 21:25
by Broker
Flash wrote:since V98 widget is broken for me

Code: Select all

Error in Update(): [string "LuaUI\Widgets\gui_idle_builders_new.lua"]:59: [GetUnitCommands] called too often without a 2nd argument to define maxNumCmds returned in the table, please check your code!
Especially when you only read the first cmd or want to check if the queue is non-empty, this can be a huge performance leak!
Hi All.
I have this problem and
unit_waypoint_dragger_2.lua
unit_obedient_constructors.lu
unit_showbuild.lua

Re: User widgets with "[GetUnitCommands] called too often" e

Posted: 10 Oct 2014, 22:34
by Silentwings
These are errors in your user widgets (that you have put in your spring/luaui/widgets folder) and are not related to BA.

You will need to update these widgets yourself, or find their authors/maintainers to update them.

The problem is that the widgets are trying to call Spring.GetUnitCommands(unitID) or Spring.GetCommandQueue(unitID) very often without a second argument. This is a potential performance drain and crashbug - 98.0 prevents it and gives the error you see. The second argument can be used to limit the size of the table returned. So you should replace e.g.

Code: Select all

Spring.GetUnitCommands(unitID) -> Spring.GetUnitCommands(unitID, 20)
All BAs widgets have already had this done (http://imolarpg.dyndns.org/trac/balatest/changeset/3324).

Re: User widgets with "[GetUnitCommands] called too often" e

Posted: 11 Oct 2014, 15:09
by jamerlan
unit_obedient_constructors.lua was fixed: link to updated obient constructors widget

Re: User widgets with "[GetUnitCommands] called too often" e

Posted: 11 Oct 2014, 17:05
by jamerlan
fixed unit_showbuild.lua url to widget

Re: User widgets with "[GetUnitCommands] called too often" e

Posted: 13 Oct 2014, 13:19
by Broker
Hi All

What does this parameter and how to understand what value must be set?

Re: User widgets with "[GetUnitCommands] called too often" e

Posted: 13 Oct 2014, 13:37
by Silentwings
See my post above.

Re: User widgets with "[GetUnitCommands] called too often" e

Posted: 13 Oct 2014, 19:59
by Broker
Silentwings wrote:See my post above.
I see it. but i don't understand way in cmd_commandinsert.lua GetCommandQueue(unit_id,100)
and cmd_customformations2.lua spGetCommandQueue(uID,5000) . what different?

Re: User widgets with "[GetUnitCommands] called too often" e

Posted: 13 Oct 2014, 20:11
by Jools
Broker wrote:Hi All

What does this parameter and how to understand what value must be set?
The second parameter sets a maximum of number of commands you request. Without the second parameter you request all commands, which is not needed if you just are going to use the first one. Well, the same information is present in the error code.

Re: User widgets with "[GetUnitCommands] called too often" e

Posted: 13 Oct 2014, 20:18
by Silentwings
i don't understand way in cmd_commandinsert.lua GetCommandQueue(unit_id,100)
and cmd_customformations2.lua spGetCommandQueue(uID,5000) . what different?
Sometimes there is a value to getting a longer section of the command queue and sometimes there isn't. For your own widget, you should make your own judgement.