For any feature requests to either the Skyline Engine or the websites and forums please leave your suggestion here.

get variable from another entity

get variable from another entity

Postby ant0N » 17 Sep 2015, 10:00

The ability to access variables in an object from another object..?

I don't know how much this is feasible, but it would be really cool! :D
For example, this is implemented as dynamicproperty:
Code: Select all
--obj1
--[[Public|int]] health = "100"


Code: Select all
--obj2
function onTrigger_Enter(hitObj)
    hitObj_health = entity.getPublicProperty(hitObj, "health")
    hitObj_health  = hitObj_health  - 1
end


any suggestions? :D
Sorry for my English. :)
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: get variable from another entity

Postby SolarPortal » 17 Sep 2015, 10:37

Using entity.getDynamicProperty(objid, "property") could be used I think but you would have to set the dynamic property in the objects script to keep it up to date. But this then defeats the purpose of the front panel as the data would change constantly and wouldn't be what u need for easy editing of shared script.

Now your public idea is pretty cool actually. But the variable would still need set every frame if called from another location or script. Probably easier to use the setVar and getVar still or simply "callfn" passing the data.

I'm not sure? If there was a way of having the data up to date without having to set anything, then it would work great. But the scripts are parsed for dynamic properties when added or saved, they are not runtime at all except for grabbing or setting.

Hope this helps :)
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: get variable from another entity

Postby ant0N » 17 Sep 2015, 11:44

I just wanted to get dccID in the trigger.

Code: Select all
function onTrigger_Enter(hitID)
    target_obj = hitID
    target_dcc = ?
end

I know that it is possible to use entity.callFn(), but then my script will lose versatility.
Sorry for my English. :)
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: get variable from another entity

Postby SolarPortal » 17 Sep 2015, 15:17

i can't seem to find a function in order to get the dccID from an entityID. I will add one in today for the next release :D
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: get variable from another entity

Postby ant0N » 17 Sep 2015, 15:35

thanks, SP! :D :D
Sorry for my English. :)
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: get variable from another entity

Postby SolarPortal » 17 Sep 2015, 17:56

ok, we now have the command:

Code: Select all
dccID = controller.getBodyID(eID) -- pass in the entity to get the dccID or -1 if not a spawned dcc


This is in for the next release.

edit: this is what it would look like in action:

Code: Select all
function onTrigger_Enter(hitID)
   dccID = controller.getBodyID(hitID);
   if(dccID ~= -1)   then
      x,y,z = controller.getPosition(dccID)
      controller.setPosition(dccID, x,y+5,z);
   end   
end
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: get variable from another entity

Postby StarFire » 17 Sep 2015, 18:27

When you get the lua action spawning update you can add a Damage action to manage all the objects health and then be able to get the object's health from the trigger. This is how I manage character health with the AI and Player. ;)
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: get variable from another entity

Postby ant0N » 17 Sep 2015, 19:28

Thanks guys! you have the best technical support! :D :P
Sorry for my English. :)
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: get variable from another entity

Postby StarFire » 17 Sep 2015, 19:32

:D
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 Feature Requests

Who is online

Users browsing this forum: No registered users and 1 guest

cron