Building interfaces part 3: sending a message to the controller script
When you want to switch to a different collection, all you need to do is use this single line of code, passing the relevant string that the controller script will be expecting.
msg.post("main:/controller","show_menu")
What does this code do?
This line of code posts a message to the controller script.
It assumes your controller collection is called 'main' and that the game object hosting the script has the Id, 'controller'.
You can use this line of code in a number of ways. For example, if you wanted to return to the menu when escape is pressed, you would set up the key trigger action to be "quit" in game.input_binding and then in the on_input function of the game collection use the script:
if action_id == hash("quit") then
msg.post("main:/controller","show_menu")
end
You will also want to use GUI buttons to trigger these scripts.