Jump to content

script


soloooy0
 Share

Recommended Posts

  "TriggerScripts": [
    "scripts/TriggerHelper.js",
    "skirmishes/YourTrigger.js", <-- this includes script to your map, path is relative to public/maps
  ],

In the script file, for example "YourTrigger.js" there need to be following section

{
	let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
	cmpTrigger.DoAfterDelay(time, "nameOfFunction", {/*parameters*/}); <- if you want to trigger function with time delay
	cmpTrigger.RegisterTrigger("OnInitGame", "InitFunction", { "enabled": true }) <- I would prefer this one
}

In InitFunction you can bind more triggers

You define any function in your trigger file with Trigger.prototype.nameOfFunction

Trigger.prototype.InitFunction = function()
{
	this.RegisterTrigger("OnOwnershipChanged", "MyOwnershipChange", { "enabled": true }); <- bind to whatever On event
	// or call any custom function in Trigger
}

To give commands to entities use ProcessCommand function

ProcessCommand(playerID, anyCommandInJsonForm);

It is good to look into TriggerHelper file to see defined functions you can already use.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...