Beside of documentation there is an example script: github.com/paweljarosz/pigeon/blob/main/main/example.script The default msg.post() calls you have in your script, could be just replaced with pigeon.send_to(), or you can utilise the subscription system and use pigeon.send() instead, but you will need to call in every recipent you wish to pigeon.subscribe() in their init() function ;) If you want to check the data, you need to define them with pigeon.define()
Hmm, Lua doesn't uses classes per se, but there are some OOP libraries, if you are thinking about something like this. And yes, you can't pass a function in a message - but you can tell the other script which function to call using a simple table with functions you can call, put it in a module and require it in both scripts (quick and dirty example): module.lua local M = {} M["test1"] = function() print("test1") end M["test2"] = function() print("test2") end return M test1.script in init(): msg.post("test2", "call_fun", "test1") test2.script requires module: local my_module = require "module" and in on_message(): if message_id == hash("call_fun") then my_module[message]() end
Looks great!
I gotta tell you I just implemented this and its great, thank you so much!
This looks awesome, looking forward to putting some time aside to try it out!
Could you please show a simple example of how to use pigeon over the default messaging system.
Beside of documentation there is an example script: github.com/paweljarosz/pigeon/blob/main/main/example.script
The default msg.post() calls you have in your script, could be just replaced with pigeon.send_to(), or you can utilise the subscription system and use pigeon.send() instead, but you will need to call in every recipent you wish to pigeon.subscribe() in their init() function ;)
If you want to check the data, you need to define them with pigeon.define()
Can we send class/subclass? As we cannot pass function through message.
Hmm, Lua doesn't uses classes per se, but there are some OOP libraries, if you are thinking about something like this. And yes, you can't pass a function in a message - but you can tell the other script which function to call using a simple table with functions you can call, put it in a module and require it in both scripts (quick and dirty example):
module.lua
local M = {}
M["test1"] = function() print("test1") end
M["test2"] = function() print("test2") end
return M
test1.script in init():
msg.post("test2", "call_fun", "test1")
test2.script requires module:
local my_module = require "module"
and in on_message():
if message_id == hash("call_fun") then
my_module[message]()
end