custom interaction command

custom interaction command

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

Moderator: Moderators

Post Reply
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

custom interaction command

Post by Erik »

What i need is basically a unit A having a custom command xyz that is issued when clicking a unit B meeting certain conditions [i.e. same team] and in those cases overrides the default behavior [guard/attack or. w/e.] for example to merge two units.

Anyone knows where to start? Is there any documentation on custom commands?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: custom interaction command

Post by jK »

User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: custom interaction command

Post by Erik »

Can't really find anything usefull there, a tutorial or sample script for commands would be cool.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: custom interaction command

Post by Jools »

Have a look in the callins: http://springrts.com/wiki/LuaCallinReturn

If the thing you want to trigger is on mouseclick, then maybe extend that command and check whether the selected unit is on your team etc... and then do the action.

You could also extend the AllowCommand command. If you return true from one of these commands then the default one won't be executed.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: custom interaction command

Post by FLOZi »

I only know of a question on custom command cursors, not one detailing how to set up a custom command (including use of UnitMoveGoal for this, probably) etc

Example gadget with custom command that uses SetUnitMoveGoal, target is an area

Another example - this one has a command where the target is a unit

Wiki page on lua commands
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: custom interaction command

Post by Anarchid »

Actually "DefaultCommand() --> nothing (???)" sounds exactly like what OP wants, and it has an example right there, linking to the thread next door.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: custom interaction command

Post by knorke »

kernel panic has some easy examples on custom commands:
bug_bombard.lua
burrow.lua

examples that adds toggle button to units:
http://springrts.com/wiki/SetMoveTypeDataExample

I would start with a custom command that is just a button (say click button=explode unit) and once that works, do commands with parameters.
Post Reply

Return to “Lua Scripts”