Location triggers are in. They require you to first register a region and an event, which will no doubt seem superfluous for the current use, I am however thinking for the future... regions will be useful for other things, and you may want more than trigger for an event. Hence the seemingly awkward approach I've taken.
XML
<?xml version="1.0" standalone="yes" ?>
<scenario>
<difficulty value="2"/>
<players>
<player control="human" faction="magic" team="1" />
<player control="cpu-ultra" faction="magic" team="2" name="Merlin" resource-multiplier="3.5" />
<player control="cpu" faction="tech" team="1" name="Bob the AI" />
<player control="cpu" faction="magic" team="2" />
</players>
<map value="conflict"/>
<tileset value="dark_forest"/>
<tech-tree value="magitech"/>
<default-resources value="false"/>
<default-units value="false"/>
<default-victory-conditions value="false"/>
<scripts>
<startup>
dofile ( scenarioDir() .. "/foo.lua" );
</startup>
</scripts>
</scenario>
Lua:
createUnit( "initiate", 0, startLocation(0) );
id = lastCreatedUnit();
giveResource( "energy", 0, 1 );
registerRegion( "centre", {56,56,11,11} );
registerRegion( "nespot", {80,40,20,20} );
registerRegion( "swspot", {25,70,25,20} );
registerEvent( "inMiddle", "region=centre" );
registerEvent( "atNorthEast", "region=nespot" );
registerEvent( "atSouthWest", "region=swspot" );
setUnitTrigger( id, "inMiddle" );
setFactionTrigger( 0, "atNorthEast" );
setTeamTrigger( 0, "atSouthWest" );
function trigger_inMiddle()
showMessage( "Middle", "..." );
end
function trigger_atNorthEast()
showMessage( "North-East expansion spot", "..." );
end
function trigger_atSouthWest()
showMessage( "South-West expansion spot", "..." );
end
NB: I don't like XML, so I put all the lua in a lua file.
function trigger_boo ()
-- some lua code
end
Is equivalent (as in, indentical) to having this in the XML:
<trigger name="boo">
-- some lua code
</trigger>