Help with your scripting

Scripts calling other scripts

Scripts calling other scripts

Postby SpiderMack » 29 Sep 2017, 12:51

Hi,

Does Skyline supports some entity script calling another entity script function ?
Is there some example ?

About functions : ds_onDamage , ds_onKo
What work these functions ? What event trigger them ? Is there some documentation ?
User avatar
SpiderMack
Skyline Expert
 
Posts: 441
Joined: 02 Dec 2016, 09:15
Skill: Concept artist
Skill: 3D Modeller
Skill: Level Designer
Skill: Scripter

Re: Scripts calling other scripts

Postby StarFire » 29 Sep 2017, 13:25

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.html

Communication, Tags and IDs
Due 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 Object
Other 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 calls
To 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");
Dream the Journey, Live the Experience!
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1678
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer

Re: Scripts calling other scripts

Postby SpiderMack » 29 Sep 2017, 15:49

Thanks for the explanation.

You should include that in some "Skyline coder guide conventions" :)

About "tags" it is like unique identifier per object always stable in Skyline, why not using object "name" instead ?

What is lacking is "tag" , the Unity way, for example several characters could have the same tag
"Can buy Object"
"Npc Quest"
"Npc Dialog"
"Clan orcs"
"Clan Magicians"
"Safe zone"
This helps to make quickly objects categories without needing scripts.
It can be used for example to check when collision or trigger happen what is object category or to give actions to some objects category. This is very usefull.
User avatar
SpiderMack
Skyline Expert
 
Posts: 441
Joined: 02 Dec 2016, 09:15
Skill: Concept artist
Skill: 3D Modeller
Skill: Level Designer
Skill: Scripter

Re: Scripts calling other scripts

Postby SolarPortal » 29 Sep 2017, 16:17

You can set the description of an entity using the properties. This can then be grabbed in lua, you could store multiple descriptions for a single entity if you string parse them apart in lua.
You can use whatever needed and these can be brought back when inside a collision, trigger volume or AI sensor.

The get description function is apart of the entity lua commands :)
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: Scripts calling other scripts

Postby StarFire » 29 Sep 2017, 16:20

It just a terminology thing..
An object tag is unique and stays the same after load back, where as an id can change. Use this to identify an object.

There is an entity description which can be used for clan, team so others can share the same description.

The object name is the name that showing in the scene entity list, now they can all say the same or be different but good housekeeping should be adhered to so team Reds barrels could be in a "Team Red" folder each respectively named barrel01, barrel02, etc and have a description of Team Red.

This could then be used as you said, other engines use a "tag", in Skyline you could use the description.
Dream the Journey, Live the Experience!
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1678
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer


Return to Lua Scripting

Who is online

Users browsing this forum: No registered users and 3 guests

cron