Skip to content

Commit 5d8fa8e

Browse files
committed
monarch.post() requires monarch.on_post()
1 parent df2a2a6 commit 5d8fa8e

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

README_API.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Remove a previously added listener.
177177

178178

179179
## monarch.post(screen_id, message_id, [message])
180-
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.
180+
Post a message to a visible screen. The screen must have set a message listener using `monarch.on_post()`.
181181

182182
**PARAMETERS**
183183
* `screen_id` (string|hash) - Id of the screen to post message to

monarch/monarch.lua

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,17 +1173,11 @@ function M.post(id, message_id, message)
11731173
assert(screens[id], ("There is no screen registered with id %s"):format(tostring(id)))
11741174

11751175
local screen = screens[id]
1176-
if screen.proxy then
1177-
if screen.receiver_url then
1178-
log("post() sending message to", screen.receiver_url)
1179-
msg.post(screen.receiver_url, message_id, message)
1180-
else
1181-
return false, "Unable to post message since screen has no receiver url specified"
1182-
end
1176+
if screen.receiver_url then
1177+
log("post() sending message to", screen.receiver_url)
1178+
msg.post(screen.receiver_url, message_id, message)
11831179
else
1184-
for id,instance in pairs(screen.factory_ids) do
1185-
msg.post(instance, message_id, message)
1186-
end
1180+
return false, "Unable to post message since screen has no receiver url specified. Set one using monarch.on_post()."
11871181
end
11881182
return true
11891183
end

0 commit comments

Comments
 (0)