hi ,
I am using collection proxy to switch between two collections,
local function loadGame(self)
msg.post("/game#gameProxy", "load")
msg.post("/game#gameProxy", "enable")
msg.post("oombi_game:/game_body#oombi1", "user_need_to_create_private_room")
end
local function unloadGame()
msg.post("/game#gameProxy", "unload")
end
local function loadLogin(self)
msg.post("/game#loginProxy", "load")
msg.post("/game#loginProxy", "enable")
end
local function unloadLogin(self)
msg.post("/game#loginProxy", "unload")
end
i need to pass game type âManualâ or auto as a parameter when load game (âloadGameâ) function,
but when i use "msg.post(âoombi_game:/game_body#oombi1â, âuser_need_to_create_private_roomâ) " it gives "Could not send message âuser_need_to_create_private_roomâ from âmain:/game#mainâ to âoombi_game:/game_body#oombi1â
The engine will send a message back to your script when the proxy is loaded, then you can send your message:
...
function on_message(self, message_id, message, sender)
if message_id == hash(âproxy_loadedâ) then
msg.post(sender, âinitâ)
msg.post(sender, "enable")
msg.post("oombi_game:/game_body#oombi1", "user_need_to_create_private_room")
end
end
Is there any new way since this post to pass parameters to collection proxy?
This is quite painful to pass a message once the collection is loaded. A simple message passing when collection is initialized would be very much appreciated.
Nope. You need to send the message manually. Or build something using Lua modules.
In the Monarch screen manager you can do something like:
-- show the game screen and pass some data to it
-- this will load the collection from a proxy
-- or spawn from a collection factory
monarch.show("game", nil, { foo = "bar" })
-------------------------------
-- read the data from a script in the loaded game screen
function init(self)
local data = monarch.data("game")
print(data.foo) -- "bar"
end