Create menu in mod

The place to post your WML questions and answers.

Moderator: Forum Moderators

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

Re: Create menu in mod

Post by LordAndrew »

Not work ! All that comes after [event] not work :evil: No event to enable the [event] I already wrote about this above. Its forever not work with InterfaceActionsWML. I will wait for the new version maby in new version will be more functional.

If i use Lua and other tags how can i include my cfg files in other cgf files ? of course that would work and executed scripts and tags
For example

Code: Select all

[tag]
[include]
/home/wesnoth/my.cfg
[/include]
[/tag]
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Create menu in mod

Post by Pentarctagon »

What's the actual WML you're currently using?
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
LordAndrew
Posts: 23
Joined: April 1st, 2018, 3:09 am
Location: Russia

Re: Create menu in mod

Post by LordAndrew »

For 1.12 version
maybe someone needs a menu framework :D I think that because of the tag [command] not give use your [event] menu and event name=menu its not work. And [event]name=menu is not an occasion for triggering.

my menu.

Code: Select all


[event]

id=my_id
name=prestart

[command]
[message]

[option]
message="return the game"
[/option]

[option]
message="swords"

[command]

[message]
caption="swords menu"

[option]
message="back to game"
[/option]

[option]
message="elvish sword"
[command]
##some wml code or not##
[/command]
[/option]

[option]
message="goblin sword"
[command]
##some wml code or not##
[/command]
[/option]

[/message]
[/command]
[/option]


[/message]
[/command]

[/event]

I think in new version developers need create some this

Code: Select all

[option_1]
message="menu1"
[/option_1]

[option_2]
message="menu2"
[call]
[option_1]
[/option_1]
[/call]
[/option_2]
or I hope Llua will work at 100% in new version :lol:
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Create menu in mod

Post by beetlenaut »

LordAndrew wrote: April 24th, 2018, 3:13 pm how can i include my cfg files in other cgf files ?
Use {curly braces} to include files or folders in .cfg files. For example,

Code: Select all

[+units]
    {campaigns/Secrets_of_the_Ancients/units}
[/units]
LordAndrew wrote: April 25th, 2018, 4:08 am I think that because of the tag [command] not give use your [event] menu
You can use [set_menu_item] and [clear_menu_item] in [command].
LordAndrew wrote: April 25th, 2018, 4:08 am And [event]name=menu is not an occasion for triggering.
But you can fire an event in a menu [command] as ForestDragon explained.

I'm sorry if I didn't understand your problem.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Create menu in mod

Post by Pentarctagon »

Yeah, I don't really understand the problem. Your code you've posted works as far as I can tell - the [message] appears and has its options.

Also, indenting helps(and the outer [command] is unnecessary):

Code: Select all

[event]
  id=my_id
  name=prestart
  
  [command]
    [message]
      [option]
        message="return the game"
      [/option]

      [option]
      message="swords"
        
        [command]
          [message]
            caption="swords menu"

            [option]
            message="back to game"
            [/option]

            [option]
              message="elvish sword"
              [command]
              [/command]
            [/option]

            [option]
              message="goblin sword"
              [command]
              [/command]
            [/option]
            
          [/message]
          
        [/command]
      [/option]
      
    [/message]
    
  [/command]
[/event]
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
LordAndrew
Posts: 23
Joined: April 1st, 2018, 3:09 am
Location: Russia

Re: Create menu in mod

Post by LordAndrew »

I want button "back to previous menu" i have three levels of the menu nested inside each other and at each level need a button. All your suggested options do not work. The variant that suggested ForestDragon works only with a simple menu. 1-2 level nested .
It's easier to make a full GUI use lua in 1.14 :D Than trying to build a spaceship with a screwdriver
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Create menu in mod

Post by Pentarctagon »

Then you need to use a [while] loop around each [message], with an [option] that sets a variable to break the current loop.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
Ravana
Forum Moderator
Posts: 3002
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Create menu in mod

Post by Ravana »

With eventbased solution you can use stack to save event names, which allows you jump back to previous event.

Similar example of that idea https://github.com/ProditorMagnus/Oroci ... #L190-L206 saves current state when going deeper, removing last state when going back.
User avatar
LordAndrew
Posts: 23
Joined: April 1st, 2018, 3:09 am
Location: Russia

Re: Create menu in mod

Post by LordAndrew »

Pentarctagon wrote: April 25th, 2018, 12:48 pm Then you need to use a [while] loop around each [message], with an [option] that sets a variable to break the current loop.
Yes it works. Thanks! I did not immediately notice that this code can be applied to a separate piece of code. I try applied to all menu :D
User avatar
LordAndrew
Posts: 23
Joined: April 1st, 2018, 3:09 am
Location: Russia

Re: Create menu in mod

Post by LordAndrew »

Ravana wrote: April 25th, 2018, 2:12 pm With eventbased solution you can use stack to save event names, which allows you jump back to previous event.

Similar example of that idea https://github.com/ProditorMagnus/Oroci ... #L190-L206 saves current state when going deeper, removing last state when going back.
1.13 and later ? I would really like to program under 1.14 I noticed a lot of interesting things there but do not have time to sit and wait :D
User avatar
Ravana
Forum Moderator
Posts: 3002
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Create menu in mod

Post by Ravana »

No.
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Create menu in mod

Post by Sapient »

LordAndrew wrote: April 25th, 2018, 12:32 pm I want button "back to previous menu" i have three levels of the menu nested inside each other and at each level need a button. All your suggested options do not work.
Ridiculous. It's beyond simple to add an option for going back to the previous menu and fire the relevant event. If you're still stuck then just tell me your menu structure and I will post some skeleton code for menu navigation.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Post Reply