Solarus-Games English Forum

Solarus => Development => Topic started by: Realguigui on November 16, 2017, 10:10:07 AM

Title: menu with parameters
Post by: Realguigui on November 16, 2017, 10:10:07 AM
Hello.
I have created a menu to manage the display and use of a digicode. It works but I would like to make it customizable to make it usable with several doors. For the moment, the secret code of the digicode and the name of the door that it opens are hardcoded in the code of the menu. This requires me to create a menu for each digicode. Would there be a way to launch my menu digicode by passing some parameters ("secret codes","door", map etc.) like a function ?
If it's not possible, is it a good idea to use some savegame_variables hardcoded in the menu that I initialize just before the lauch of the digicode's menu ?

Thank you
Title: Re: menu with parameters
Post by: Diarandor on November 16, 2017, 12:21:29 PM
You don't need to code a menu for each door. You can pass all the necessary info from the door to the menu with an initialization function.
Title: Re: menu with parameters
Post by: Realguigui on November 16, 2017, 01:52:58 PM
Quote from: Diarandor on November 16, 2017, 12:21:29 PM
You don't need to code a menu for each door. You can pass all the necessary info from the door to the menu with an initialization function.

It's not clear for me. Can you tell me where I can found some examples ?
Title: Re: menu with parameters
Post by: Diarandor on November 16, 2017, 02:22:54 PM
An example of menu is the inventory menu (the pause menu). You can download any project made by Christopho and study these scripts.

Doors do not have collision tests or events like "on_interaction" or "on_activated", so you should use other entity to detect the interaction somehow and then start the menu. So you really need 2 entities, the door, and other entity to detect the interaction (and you can start the menu when there is interaction with this entity, defining that interactin event from the map script, which would start you menu and initialize it with the particular info).

(Sorry if I don't give more explanations, I am a bit busy. But I'm sure others can help you more if my hints are not enough for you.)
Title: Re: menu with parameters
Post by: Realguigui on November 16, 2017, 11:42:22 PM
the good thing is that I use a custom entitie to launch the menu exactly like you said. The bad thing is that the scripts of pause menu are very complex and I don't find any help in them.

Thanks anyway.