Scripting: Communication with Modules

Not all dynamic controllers are created by script. In some situations it is easier and better for performance to use the module system.
Skyline will happily run an object containing both a script, either external or micro script and a visual module graph. Tools have been provided for inter system communication between scripts and modules, lets take a look.

callModuleEvent() - To call a module

From within a lua script, you can call the lua module event command. This will then be picked up in the targetID graph, and be used to cause the receiving module to pass a module Event signal.

-- | ARGUMENTS -- callerID, targetID, key, type, value
-- | param: objID - is the id of the entity calling the module. This should be obj or objID.
-- | param: targetID - is the id of the target entity we want trigger the event on. This can be itself as the same entity may contain a script, and a graph.
-- | param: key - identifier is the name attached to the target module "Lua Event"
-- | param: type - is either "int", "float", "bool", "string", etc...
sky.callModuleEvent(objID, targetID, "stopActivate", "int", "1")

In the object with the ID of targetID, you would then require a receiving module.

Receiving Module

In the receiving objects graph, use the “Lua Event” module located in the category “Lua”. This module requires a key identifier,sent from the lua command. Upon a call from sky.callModuleEvent(..), this module will send an Event signal and the received value, out of its connectors.

Module to script communication

The final way of communicating is from module into a lua script. This is used as such:

If you are calling a microscript, then the bottom property needs to be set to checked using a Boolean variable module. If its an external script, then leave it as it is shown in the picture above.

Receiving script

Any signal passed from a module can be received by a Lua script function of the same name passed into the module. ie:

function PlayerKO( eID, value)
   -- ..... run code .....

As you can see, there are plenty of ways of communicating in skyline. There are also action setters and getters, nut this is for another time…