Lua mission builder
Moderator: Moderators
Lua mission builder
Can someone please direct me to a tutorial on building singleplayer missions using either the lua mission builder in .73b1 or using the script template included in the install.
I have read through the example script and can see how everything is set up (units & buildings added etc) but cannot fathom how these are assigned a behaviour (ie what makes the factory keep making groups of units and sending them at you and what makes the builders keep building mexs and solars (is there a handover of all units at startup to a builtin version of AAI of NTAI?)
A pointer on using the lua mission builder in spring would be awesome too. I have combed through the wiki trying to find something and have searched previous posts with out much luck.
Cheers
I have read through the example script and can see how everything is set up (units & buildings added etc) but cannot fathom how these are assigned a behaviour (ie what makes the factory keep making groups of units and sending them at you and what makes the builders keep building mexs and solars (is there a handover of all units at startup to a builtin version of AAI of NTAI?)
A pointer on using the lua mission builder in spring would be awesome too. I have combed through the wiki trying to find something and have searched previous posts with out much luck.
Cheers
- Felix the Cat
- Posts: 2383
- Joined: 15 Jun 2005, 17:30
As far as I can tell there is no tutorial - I've tried looking for some guidance on how to build scenarios before, to no avail.
Last time I asked about it, I was told that the Lua interface was barely functional... I don't know if it's changed since then (it's been a few versions), hopefully it has...
Last time I asked about it, I was told that the Lua interface was barely functional... I don't know if it's changed since then (it's been a few versions), hopefully it has...
- Felix the Cat
- Posts: 2383
- Joined: 15 Jun 2005, 17:30
http://taspring.clan-sy.com/phpbb/viewt ... 8680#98680
Basically, the basic functionality is there, but not enough to make a propper mission. Or maybe the extra stuff IS there, we just dont know about it, cause there is NO documentation at all
If a kind dev/source-code-monekey would check out the LUA binding and at least tell us what functions are avaliable to us it would be MUCH apreciated.
Basically, the basic functionality is there, but not enough to make a propper mission. Or maybe the extra stuff IS there, we just dont know about it, cause there is NO documentation at all

If a kind dev/source-code-monekey would check out the LUA binding and at least tell us what functions are avaliable to us it would be MUCH apreciated.
cheers for the advice.
Found out where the old testscript was broken too... rather than "loadunit" it should read. "units.load", easy enough to fix doing a "find and replace" type operation.
Maelstrom, if you know it, can you post the syntax for getting a factory to build a unit and how to return a pointer to that unit (ie so that it can be added to a list object for giving orders easily)
I was thinking of writing a kill the gate (or blow up the supply tunnel for the '44 enthusiast) mission. Kinda similar to the random spawn scripts (along with the progressing difficulty) except you've got a base to get through to get to the gate.
I reckon it'd be almost possible to set up a gaia player this way as well, I'm going to eperiment with setting up two ai teams with prebuilt bases which just throw units at each other (and yes you guessed it -from gates
)
I presume that by not setting the singleplayer only tab and setting the gaia team numbers as say 7 or 8 I will also be able run lan games along side the gaia teams.
EDIT: perhaps somebody knows the syntax for assigning a unit one of the ai's as well? ie the economy ai
Found out where the old testscript was broken too... rather than "loadunit" it should read. "units.load", easy enough to fix doing a "find and replace" type operation.
Maelstrom, if you know it, can you post the syntax for getting a factory to build a unit and how to return a pointer to that unit (ie so that it can be added to a list object for giving orders easily)
I was thinking of writing a kill the gate (or blow up the supply tunnel for the '44 enthusiast) mission. Kinda similar to the random spawn scripts (along with the progressing difficulty) except you've got a base to get through to get to the gate.
I reckon it'd be almost possible to set up a gaia player this way as well, I'm going to eperiment with setting up two ai teams with prebuilt bases which just throw units at each other (and yes you guessed it -from gates

I presume that by not setting the singleplayer only tab and setting the gaia team numbers as say 7 or 8 I will also be able run lan games along side the gaia teams.
EDIT: perhaps somebody knows the syntax for assigning a unit one of the ai's as well? ie the economy ai
The only functions are
from rts\system\script
Code: Select all
namespace luafunctions
{
void EndGame();
void UnitGiveCommand(CObject_pointer<CUnit>* u, Command* c);
CObject_pointer<CUnit>* UnitGetTransporter(CObject_pointer<CUnit>* u);
void CommandAddParam(Command* c, float p);
CObject_pointer<CUnit>* UnitLoaderLoadUnit(std::string name, float3 pos, int team, bool buil);
int GetNumUnitsAt(const float3& pos, float radius);
luabind::object GetUnitsAt(lua_State* L, const float3& pos, float radius);
std::string MapGetTDFName();
luabind::object GetSelectedUnits(lua_State* L, int player);
void SendSelectedUnits();
};
- PauloMorfeo
- Posts: 2004
- Joined: 15 Dec 2004, 20:53
I concur.diggz2k wrote:I think we should add easy to use and versatile mission scripting to the mtr
...
These are two things that need to be on our most wanted list.
Anything, and i mean anything, that allows for the computer to have a big base for us to blow the crap out of it, or better, would be quite worth it. Even for non-newbies, as i, often, want to just pound the PC a little.
Cheers for the link nimbus.
Any idea on what the parameters are to queue commands (ie sending units via a particular route like the current waypoint system) or to set the parameters for the area commands?
ie if I spawn a whole bunch of units in an area, how do I call the area load command for a transport to pick them all up? does this have to be done "the hard way" (scripting in individual locations and then waiting for these actions to be done before entering in new script commands)?
I also need to know how to set allies between different teams through the script? -Both of my gaia players are hostile
I have got a working two base system going with units being spawned near to gates (the idea is kill the gate and the units stop coming kind of thing).
Unfortunately at this point I am completely limited to scriptable actions so untill I get the nukes working it will be a bit predictable.
It may be interesting to do a sort of squad training thing... force people to micro a small amount of units around existing bases eg warcraft 3, with another squad being spawned in when the originals have all been destroyed
Any idea on what the parameters are to queue commands (ie sending units via a particular route like the current waypoint system) or to set the parameters for the area commands?
ie if I spawn a whole bunch of units in an area, how do I call the area load command for a transport to pick them all up? does this have to be done "the hard way" (scripting in individual locations and then waiting for these actions to be done before entering in new script commands)?
I also need to know how to set allies between different teams through the script? -Both of my gaia players are hostile

I have got a working two base system going with units being spawned near to gates (the idea is kill the gate and the units stop coming kind of thing).
Unfortunately at this point I am completely limited to scriptable actions so untill I get the nukes working it will be a bit predictable.
It may be interesting to do a sort of squad training thing... force people to micro a small amount of units around existing bases eg warcraft 3, with another squad being spawned in when the originals have all been destroyed
- Michilus_nimbus
- Posts: 634
- Joined: 19 Nov 2004, 20:38
I've tried to do some of that stuff myself.
Setting teams as allies doesn't seem to be possible. In fact, Spring crashes if you try to assign units to a team other than 0 or 1. This is something I'd seriously like to see fixed/implemented.
The atlas behaviour you mention could probably be implemented by doing a slow update with units.GetAt(float3,radius), and giving the atlas load/unload orders as long as there are units in the table. But I do agree having every command available would be very, very handy indeed.
Setting teams as allies doesn't seem to be possible. In fact, Spring crashes if you try to assign units to a team other than 0 or 1. This is something I'd seriously like to see fixed/implemented.
The atlas behaviour you mention could probably be implemented by doing a slow update with units.GetAt(float3,radius), and giving the atlas load/unload orders as long as there are units in the table. But I do agree having every command available would be very, very handy indeed.
- Michilus_nimbus
- Posts: 634
- Joined: 19 Nov 2004, 20:38
Bumpitydo.
Messing around with the luabinder code, I've managed to set the two teams as allies through the script. The problem is, vision is shared, but radar isn't. The ally doesn't show up on the minimap either.
Adding to the lua interface doesn't seem to difficult. Adding it decently is another matter.
Messing around with the luabinder code, I've managed to set the two teams as allies through the script. The problem is, vision is shared, but radar isn't. The ally doesn't show up on the minimap either.
Adding to the lua interface doesn't seem to difficult. Adding it decently is another matter.
Bumpish. If anyone gets this working, would they mind posting their code? This feature could be a lot of fun if its used well. Although crafting an entire campaign would be a bit much, a handful of linked missions for various mods (EE, Gundam, SWS, and 1944 stand out as mods that would be easy to tie to an interesting story and objective oriented missions)
I'm really looking forward to when full blown mission building becomes more popular - in some game communities I've seen, it rivals mapping in popularity.
I'm really looking forward to when full blown mission building becomes more popular - in some game communities I've seen, it rivals mapping in popularity.
Here is my WIP so far
http://www.fileuniverse.com/?p=showitem&ID=3983
todo:
-get nimbuses code to set allies off him somehow!
-workout how to get the mission builder to include nonselectable items such as dragons teeth (thats why my base looks so weird... it had some fairly impressive fortification patterns when I started.
-incorporate the gates and build in the behaviour "if gate dies units stop coming"
-work out how to spawn a true ai player such as AAI into the game.
-work out how to code in waypoints... may have to just check if units are at a way point then send them off to the next one.
Please do not think that this is complete by any means. I am posting this as a draft so that the more experienced coders out there can help me with the issues I have described above
http://www.fileuniverse.com/?p=showitem&ID=3983
todo:
-get nimbuses code to set allies off him somehow!
-workout how to get the mission builder to include nonselectable items such as dragons teeth (thats why my base looks so weird... it had some fairly impressive fortification patterns when I started.
-incorporate the gates and build in the behaviour "if gate dies units stop coming"
-work out how to spawn a true ai player such as AAI into the game.
-work out how to code in waypoints... may have to just check if units are at a way point then send them off to the next one.
Please do not think that this is complete by any means. I am posting this as a draft so that the more experienced coders out there can help me with the issues I have described above
- Michilus_nimbus
- Posts: 634
- Joined: 19 Nov 2004, 20:38
Well, I did it by modifying the lua interface, so you won't be able to just get it working on your side.-get nimbuses code to set allies off him somehow!
I can send you a modified spring.exe, but since I can only compile it with mingw, I don't think dumping it in your spring folder would work, so you'd probably have to download one of those auto builds to make it work. Anyhow, I'll post it today.
I basically added a gs.SetAlly(teamA,teamB,true/false) function, and also a stats.UnitsKilled(team nr)/stats.UnitsLost(team nr) function. I don't think it's properly implemented though. Spring likes crashing if you don't put SetAlly in the class constructor, and the stats functions like to ruin the party too sometimes.