custom commands that don't erase the order queue when given without shift?

custom commands that don't erase the order queue when given without shift?

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

Moderator: Moderators

Post Reply
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

custom commands that don't erase the order queue when given without shift?

Post by Silentwings »

Some commands, such as CMD.ATTACK, if given without the shift modifier, will overwrite the units current order queue. Others, such as CMD.ONOFF, won't. Is there a way for a custom command to decide which of these behaviours it wants? If not, feature request please - the default is the first case and I haven't found a clean way to get second.

(The reason: since custom commands are implemented in lua anyway, one can hackily workaround the issue by returning false in gadget:AllowCommand for the custom command; the order queue is then preserved but it has the unwanted side effect that then in some cases LuaUI & elsewhere sees it as though the command was never given. For example, see BAs CMD.PASSIVE with a factory and note that widget:UnitCommand is not called because gadget:AllowCommand returned false.)
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: custom commands that don't erase the order queue when given without shift?

Post by Kloot »

Is there a way
Nope, the set of non-queueing commands (which are those that toggle state) is hardcoded.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: custom commands that don't erase the order queue when given without shift?

Post by Silentwings »

Ah well, thanks, low priority feature request :)
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: custom commands that don't erase the order queue when given without shift?

Post by Google_Frog »

Just return false in gadget:AllowCommand. This is always how I have implemented state toggles and I never noticed a problem. I have not used widget:UnitCommand for toggles but if you need it to trigger then send the UnitCommand to LuaUI directly. For example: https://github.com/ZeroK-RTS/Zero-K/blo ... events.lua
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: custom commands that don't erase the order queue when given without shift?

Post by Silentwings »

I appreciate that's possible but I'm not going to start artificially forwarding the native callins to LuaUI, allowing it looks like a first step down the slippery slope of hackiness. Prefer to just wait.
Post Reply

Return to “Lua Scripts”