Help with your scripting

entity.callFn()

entity.callFn()

Postby ant0N » 11 Mar 2015, 17:19

is there a way to send a message to all entities of the scene?
function callFn() requires you to specify a specific target...
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: entity.callFn()

Postby SolarPortal » 11 Mar 2015, 17:36

yes, you can call "sky.callGlobalFn(obj,1);" and use the "function globalFn( callingID, value )"

Here it is in the API with an example:
http://www.chi-ad.com/Skyline/API/Lua/html/classsky.html#a6d962912a74feda8d6995b3f5c94f06a

Edit: If you need to call it in the initialiser, then call it in the postInit() instead of the onInit() to make sure everything is setup.
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: entity.callFn()

Postby ant0N » 11 Mar 2015, 17:38

SolarPortal, thank you!!! I remember what it saw somewhere, but couldn't find. :lol:
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: entity.callFn()

Postby SolarPortal » 11 Mar 2015, 17:40

no worries :) Glad its working for you :)
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: entity.callFn()

Postby ant0N » 11 Mar 2015, 17:57

I think this feature can improve! :D
sky.callGlobalFn(obj,message,data);
message - this filter. below it will be clear why.
data - can be a number, string, or table.

example:
Code: Select all
    if input.keyHit( "q" ) ==1 then sky.callGlobalFn(obj,"fire",1) end
    if input.keyHit( "e" ) ==1 then sky.callGlobalFn(obj,"kill",1) end

------------------------------------------------
Code: Select all
function globalFn( callingID, message, data)
    if callingID == playerID then
        if message == "fire" then
           --//////
        elseif message =="kill" then
            --/////
        end
    end
end
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: entity.callFn()

Postby SolarPortal » 11 Mar 2015, 18:02

currently, the value (2nd argument) is a string, which means you can send through any number or string through already.
We can add an extra argument though. Would be good to send tables through as that is the only thing that won't work so far.
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


Return to Lua Scripting

Who is online

Users browsing this forum: No registered users and 2 guests