Create menu in mod

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
User avatar
LordAndrew
Posts: 23
Joined: April 1st, 2018, 3:09 am
Location: Russia

Create menu in mod

Post by LordAndrew » April 3rd, 2018, 5:33 pm

Hi ! I want to create menu box in game. How to make a return to the previous menu ?
Below I'll give you the code of what I want

Code: Select all

[message]
speaker=narrator
caption="tutle"
message="You are in menu"

[option]
message=" "Return to the game"
[/option]

[option]
message="choose1"
[/option]

[option]
message="choose2"
[/option]

[option]
message="choose3"
[command]
[message]
[option]
message="return previous menu"
[/option]
[option]
[command]
[message]
message="choose3.1"
[/command]
[/option]
[/message]
[/command]
[/option]
[/message]
[/command]
[/option]
How call dialog message "you are in menu" ? :oops:
Last edited by Ravana on April 3rd, 2018, 5:49 pm, edited 1 time in total.
Reason: Use [code] without [spoiler]

User avatar
Ravana
Moderator
Posts: 1697
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: Create menu in mod

Post by Ravana » April 3rd, 2018, 5:51 pm

Loop or fire_event might be easiest to use.

User avatar
LordAndrew
Posts: 23
Joined: April 1st, 2018, 3:09 am
Location: Russia

Re: Create menu in mod

Post by LordAndrew » April 3rd, 2018, 6:22 pm

How it can help me ? I dont use unit or attack. its only text dialog NO id NO name
https://wiki.wesnoth.org/InternalAction ... e_event.5D
(Version 1.13.6 and later only)
I dont know how it loop. put menu in menu in menu in menu...... :D

User avatar
Ravana
Moderator
Posts: 1697
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: Create menu in mod

Post by Ravana » April 3rd, 2018, 6:38 pm

For loop examples most of addons with shop should work, with fire_event I have done it as https://github.com/ProditorMagnus/Agele ... #L168-L175 https://github.com/ProditorMagnus/Agele ... nu.cfg#L76

User avatar
LordAndrew
Posts: 23
Joined: April 1st, 2018, 3:09 am
Location: Russia

Re: Create menu in mod

Post by LordAndrew » April 10th, 2018, 6:54 am

How it work ? If use [event] i dont see my menu and how it can work if [fire_event] support name and id only for version 1.13.6 and later ? nonsense and untruth. Maby this ageless mod (menu) work only 1.11 version or brake ?

User avatar
Ravana
Moderator
Posts: 1697
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: Create menu in mod

Post by Ravana » April 10th, 2018, 10:05 am

"Optional" is devfeature not name. You can try that menu out, though with 1.13 it is quite difficult since it changed how deselecting unit works.

User avatar
LordAndrew
Posts: 23
Joined: April 1st, 2018, 3:09 am
Location: Russia

Re: Create menu in mod

Post by LordAndrew » April 10th, 2018, 1:36 pm

In version 1.12 it is impossible to make a return to the previous menu as it is easier ? Not overwriting everything. How can I add ID or NAME to tag [option], [command], ? Tag [command] can call previous [option] ?
Then developers need to add in the new version ID and NAME (class,variable) for all tags. As in the php javascript and other

User avatar
ForestDragon
Forum Regular
Posts: 1409
Joined: March 6th, 2014, 1:32 pm

Re: Create menu in mod

Post by ForestDragon » April 10th, 2018, 5:25 pm

menu loops can be made like this (to get the desired results, you might want to put [while]/[do] loops into eachother):

Code: Select all

        [set_variable]
            name=shoppingdone
            value=no
        [/set_variable]
        [while]
            [variable]
                name=shoppingdone
                equals=no
            [/variable]
            [do]
                [message]
                    speaker=narrator
                    message= _ "menu text"

                    [option]
                        message= _ "exit menu (or enter previous sub-menu)"
                        [command]
                            [set_variable]
                                name=shoppingdone
                                value=yes
                            [/set_variable]
                        [/command]
                    [/option]
                    [option]
                        message=  {MENU_IMG_TXT "attacks/bow-short.png" _"menu option (looped)"}
                        [command]
#insert menu content
                        [/command]
                    [/option]
                [/message]
            [/do]
        [/while]
Co-creator of Era of Magic
Creator of Tale of Alan (abandoned) and The Golden Age (1.12/1.13, temporarily abandoned again),XP Bank (1.12/1.13),Alliances Mod(1.12),my franken-art
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

User avatar
Sapient
Developer
Posts: 4429
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Create menu in mod

Post by Sapient » April 11th, 2018, 6:17 am

And this would be how to do it with fire_event :

Code: Select all

      #define SHOPMENU NUM
        [fire_event]
          name=shopmenu {NUM} 
        [/fire_event]
      #enddef
      [event]
        name=shopmenu 1
        first_time_only=no
        [message]
          speaker=narrator
          message= _ "Welcome to the Shop! This is a Menu!"
          [option]
            message= _ "exit menu"
            [command]
            [/command]
          [/option]
          [option]
            message=  {MENU_IMG_TXT "attacks/bow-short.png" _"menu option (and keep shopping)"}
            [command]
# TO DO: do something here
              {SHOPMENU 1}
# then keep shopping!
            [/command]
          [/option]
        [/message]
      [/event]
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."

User avatar
LordAndrew
Posts: 23
Joined: April 1st, 2018, 3:09 am
Location: Russia

Re: Create menu in mod

Post by LordAndrew » April 11th, 2018, 10:55 am

ForestDragon
Yes its work ! But to make this functional for subcategories in categories i cant.

Sapient.
Its goodly but no events for triggering tag [event] for this reason it will never work. If i use this construction me need put [event] in [event] i think its slow down game.

User avatar
Sapient
Developer
Posts: 4429
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Create menu in mod

Post by Sapient » April 11th, 2018, 11:04 am

Don't worry about efficiency concerns... this is menu display code, not heavy computation. It's quite simple to make another menu, "shopmenu 2", using a separate event, then to call that from the first menu. Why don't you try it? If you have trouble then I'd be glad to help.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."

User avatar
LordAndrew
Posts: 23
Joined: April 1st, 2018, 3:09 am
Location: Russia

Re: Create menu in mod

Post by LordAndrew » April 11th, 2018, 11:47 am

Ok. And how i can call this [event] name=menu ?

User avatar
ForestDragon
Forum Regular
Posts: 1409
Joined: March 6th, 2014, 1:32 pm

Re: Create menu in mod

Post by ForestDragon » April 11th, 2018, 11:49 am

LordAndrew wrote:
April 11th, 2018, 11:47 am
Ok. And how i can call this [event] name=menu ?
by putting a [fire_event] into [command]
Co-creator of Era of Magic
Creator of Tale of Alan (abandoned) and The Golden Age (1.12/1.13, temporarily abandoned again),XP Bank (1.12/1.13),Alliances Mod(1.12),my franken-art
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

User avatar
LordAndrew
Posts: 23
Joined: April 1st, 2018, 3:09 am
Location: Russia

Re: Create menu in mod

Post by LordAndrew » April 11th, 2018, 12:02 pm

I can bind hotkeys ? if i use [event] in menu . For fast access separate (individual) menu

User avatar
ForestDragon
Forum Regular
Posts: 1409
Joined: March 6th, 2014, 1:32 pm

Re: Create menu in mod

Post by ForestDragon » April 11th, 2018, 12:23 pm

LordAndrew wrote:
April 11th, 2018, 12:02 pm
I can bind hotkeys ? if i use [event] in menu . For fast access separate (individual) menu
it can be done by putting something like this into the [set_menu_item]:

Code: Select all

        [default_hotkey]
            key=r
        [/default_hotkey]
Co-creator of Era of Magic
Creator of Tale of Alan (abandoned) and The Golden Age (1.12/1.13, temporarily abandoned again),XP Bank (1.12/1.13),Alliances Mod(1.12),my franken-art
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

Post Reply