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

System messages [DONE]

System messages [DONE]

Postby ant0N » 01 Dec 2012, 11:16

not found in the Skyline of this very useful function.
Code: Select all
message(object, $message, delay, data )

*if message = "*", then the message is sent to all objects in the scene.
*data - any data, a string, number, Vec3, etc.

Code: Select all
function ResiveMessage(message, extra)
end


Example:
-- Player script
Code: Select all
function onUpdate( timeDelta )
   if (input.keyDown("f")==1) then
       message(getEntityIDFromTag("flashlight"), "ON", 0)
   end
end


-- flashlight script
Code: Select all
function ResiveMessage(message, extra)
   if (message == "ON") then
       --the activation code of the flashlight
   end
end
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: System messages

Postby StarFire » 01 Dec 2012, 11:53

great idea! :D

We do have the new command:
Code: Select all
entity.callPublicFn(obj,entity.getLastHitEntityID(),bulletDamage);

but this only sends to the specified object script. To have a Broadcast Event where all scripts can hear the message would be really useful.
ie. Turn on the light switch and all 5 lights in the room turn on

Added to the feature request list, I will try to get this in for the next version release ;)
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: System messages

Postby StarFire » 18 Dec 2012, 23:09

Just added a global broadcast to all scripts:

Code: Select all
sky.callGlobalFn(int objID, value);


and in each script the event callback is:

Code: Select all
function globalFn(callingID, value)

end


See the new tech demo - Physics Demo 02 as this dynamically creates a few physics objects and sends them to sleep so they do not move. Then by hitting the space bar a callGlobalFn(...) is made which is picked up by globalFn(callingID, value) in all of the spawned objects, this function is set to awaken them and they fall to the ground.
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 4 guests