From 5d8fa8e2203c56071c769786d21996822a46a93c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ritzl?= Date: Thu, 3 Aug 2023 08:35:04 +0200 Subject: [PATCH] monarch.post() requires monarch.on_post() --- README_API.md | 2 +- monarch/monarch.lua | 14 ++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/README_API.md b/README_API.md index 815e9cd..38fcb10 100644 --- a/README_API.md +++ b/README_API.md @@ -177,7 +177,7 @@ Remove a previously added listener. ## monarch.post(screen_id, message_id, [message]) -Post a message to a visible screen. If the screen is created through a collection proxy it must have specified a receiver url. If the screen is created through a collection factory the function will post the message to all game objects within the collection. +Post a message to a visible screen. The screen must have set a message listener using `monarch.on_post()`. **PARAMETERS** * `screen_id` (string|hash) - Id of the screen to post message to diff --git a/monarch/monarch.lua b/monarch/monarch.lua index 85426e3..3975619 100644 --- a/monarch/monarch.lua +++ b/monarch/monarch.lua @@ -1173,17 +1173,11 @@ function M.post(id, message_id, message) assert(screens[id], ("There is no screen registered with id %s"):format(tostring(id))) local screen = screens[id] - if screen.proxy then - if screen.receiver_url then - log("post() sending message to", screen.receiver_url) - msg.post(screen.receiver_url, message_id, message) - else - return false, "Unable to post message since screen has no receiver url specified" - end + if screen.receiver_url then + log("post() sending message to", screen.receiver_url) + msg.post(screen.receiver_url, message_id, message) else - for id,instance in pairs(screen.factory_ids) do - msg.post(instance, message_id, message) - end + return false, "Unable to post message since screen has no receiver url specified. Set one using monarch.on_post()." end return true end