Its a simple quiz game. Player answers the question and answer is shown. Uses Monarch screen manager and Druid UI. Project structure is:
- main
– screens
— answer.collection
— answer.gui
— answer.gui_script
— quiz.collection
— quiz.gui
— quiz.gui_script
in quiz.gui_script i have:
local function on_answer_button_callback(self)
msg.post("answer:/screen#gui", "answered", { answer_explanation = "ANSWER!" })
end
and in answer.gui_script
function on_message(self, message_id, message, sender)
monarch.on_message(message_id, message, sender)
self.druid:on_message(message_id, message, sender)
if message_id == hash("answered") then
local _answer_explanation = message.answer_explanation
local answer_explanation_text_node = gui.get_node("answer_explanation_text")
gui.set_text(answer_explanation_text_node, _answer_explanation)
print("Received answer_explanation:", _answer_explanation)
end
end
Problem is, message is not passed from one script to another ie. quiz.gui_script to answer.gui_script. Always get error message: Could not send message ‘answered’ from ‘quiz:/quiz#screen’ to ‘answer:/screen#gui’.
IDs for collections are correct - “quiz” and “answer” with “screen” game object with “gui” in both colelctions