As for the documantation, I am currently putting this together here is an excerpt: also cheack the API on events
http://www.chi-ad.com/Skyline/API/Lua/h ... vents.htmlCommunication, Tags and IDsDue to Skylines game objects acting like self-contained programs we have a method for objects and the game systems to communicate with each other. This is done by identifiers for locating specific objects and the ability to call your own events which are functions living in another object. This way we can notify an object that something has happened and / or send some data to the other object. By using this we can create and control some very complex relationships between these objects enabling all sorts of game mechanic dynamics.
Identifiers – Tag or ID?We can get the id of an object in the scene by using its property panel, but this can have an issue if for whatsoever reason this objects id is changed due to a scene reordering itself after another object has been deleted. To get around this we advise the use of “Tag Names”, every entity in the scene has a unique tag name, no two entities can have the same tag name.
NOTE: You will notice the term “entity” not “object”, as all objects are entities but not all entities are objects. E.g. lights, empty nodes, meshes are entity types. Objects are generally more than an entity, a combination of actions, scripts, modules and .
So to know the identity of another object we use its unique Tag Name.
Know yourself – Parent ObjectOther than a scene script a script is attached to an object. This objects ID is passed into any attached script in the form of an event arg. It’s common to see the variable “obj” in Skylines scripts. We use this as a global variable, only to this script, containing this parent objects id. Now we have this id we can send it to other objects if requested by them. The id is passed into the script by the onInit(objID) event function, so you would see:
Obj = -1; -- Create our global variable to store the objects id.
Function onInit(objID) -- Event called after you press the play button, this scripts game entry point.
obj = objID; -- The id of this object at the time of pressing the play button or end game starting up.
end
Special Event callsTo call communicate with another object we can use a special command to call a function in a target object script, and if required pass some data between these objects. To do so we have a few option (targetID is the id of the object you are calling).
• Global Call – Sends out to all objects with a script. – sky.callGlobalFn(obj,value);
• Call to a specified Object. - entity.callPublicFn(obj,targetID,value);
• Call to specific objects function - entity.callFn(obj,targetID,"anyFunction",arg1);
Ok I hear you say “You said don’t use ID’s, use tags instead!” and I did. What we need to do to get a “targetID” is use the objects tag name and a neat command to get the id from the tag.
targetID = entity.getIDFromTag("Object_Tag_Name");