Precedence of Commands...

Precedence of Commands...

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

Moderator: Moderators

Post Reply
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Precedence of Commands...

Post by Argh »

Basically, I'd like to alter the precedence of certain commands, and I was wondering whether this is at all possible with Lua at present.

For example... if you have a unit that's armed, and you move your mouse over another unit, it will Attack. Even if the Unit is supposed to, say, Capture stuff, or use Reclaim to suck them up, and the "weapon" is a dummy, used for another purpose. Yeah, I know you can make CanAttack == 0, but that's not what I mean here, it's not just this specific problem.

Is there any way to re-order which commands are the default, for a given situation, or is this entirely hard-coded?
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Precedence of Commands...

Post by KDR_11k »

gadget:DefaultCommand() (unsynced)

Exists for widgets too. Look into Fibre for an example.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Precedence of Commands...

Post by Argh »

Thanks very much, KDR! I've written a modified version for P.U.R.E., it'll be included in the World Builder archive.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Precedence of Commands...

Post by Argh »

Drat. On further testing, this isn't going to work. Meh, what I need is to change the command conditionally. I should probably explain what I actually need to do :roll:

Basically, in P.U.R.E., EngineeringTeams (builder units) can Capture and can Reclaim. Spring always puts Builder Units on Reclaim, if they can Reclaim, if the mouse is released over a non-friendly Unit. I want to make it select Capture, instead, because alpha-testers have found this confusing.

Just for that Unit, mind ye, not for everything that can Reclaim / Capture.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Precedence of Commands...

Post by KDR_11k »

Er, that's pretty damn easy? Look at Fibre again, you don't e.g. get the Align command for factories, you get Move Beacon instead. To make the cursor change based on the target you need a widget as it is used in KP to implement the packet Enter command.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Precedence of Commands...

Post by Argh »

To make the cursor change based on the target you need a widget as it is used in KP to implement the packet Enter command.
Yeah, that's what I need. I'll take a look. Sorry, if this seems easy or whatever, I just haven't gotten into that area yet, my custom stuff is mainly having to do with Lua --> COB interactions, not all-Lua stuff. This was a special case, basically, I hadn't run into this problem before.
Post Reply

Return to “Lua Scripts”