[solved] Adding a message instead of an option in menu
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.
-
- Posts: 1187
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
[solved] Adding a message instead of an option in menu
This is from LotI, .../utils/chapter9_utils.cfg
And that's fine, but when I don't have enough gold I'd still like to know how much I'd need. I tried inserting this between the two option blocks first, and it's as close as I've gotten:
This works, and it's close. The problem is it's a clickable option which closes the menu if selected. I just want it to be a message, or maybe an option with a null command that doesn't close the menu. Or something, I don't know the proper terms. I've tried a number of approaches -- and failed.
I did try to rtfm, but all I can find on wml is "How to code Hello World" and "Command reference for the people who already really know what they're doing and that's not you". Nothing in between, unfortunately.
TIA
Code: Select all
[message]
speaker=narrator
image="wesnoth-icon.png"
message=$intro_message
# .... SNIP ....
[option]
label=_ "Buy space to recall more units automatically ($next_autorecall_price)"
[show_if]
[variable]
name=gold
greater_than_equal_to=$next_autorecall_price
[/variable]
[/show_if]
[command]
[gold]
side=1
amount="$(-1*$next_autorecall_price)"
[/gold]
{VARIABLE_OP max_autorecall add 1}
[/command]
[/option]
[option]
label=_ "Back"
[command]
[/command]
[/option]
[/message]
Code: Select all
[option]
label=_ "Not enough gold to buy space to recall more units automatically (need $next_autorecall_price)"
[show_if]
[variable]
name=gold
less_than=$next_autorecall_price
[/variable]
[/show_if]
[/option]
I did try to rtfm, but all I can find on wml is "How to code Hello World" and "Command reference for the people who already really know what they're doing and that's not you". Nothing in between, unfortunately.
TIA
Last edited by white_haired_uncle on June 1st, 2023, 5:15 pm, edited 1 time in total.
Re: Adding a message instead of an option in menu
Isn't it worth an [if] before the [message] that detect the gold conditions, and returns a [message] or another according to the conditions?
- Pentarctagon
- Project Manager
- Posts: 5565
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Adding a message instead of an option in menu
There isn't a way to not close the menu after selecting an option. What you can do instead is wrap the [message] in a loop (ie: [while]), so that it continues showing the [message] until an option is chosen that causes the loop to stop.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
-
- Posts: 1187
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
[solved] Adding a message instead of an option in menu
Thank you. I was hoping maybe there was an alternative to [option], or maybe a way to make it non-selectable. Seems like this would be a rather common desire, to show an option that is not currently available (and why).
As it turns out the [while] approach worked perfectly. I actually wanted to use that anyway for a different reason, but it fixed this issue as well.
As it turns out the [while] approach worked perfectly. I actually wanted to use that anyway for a different reason, but it fixed this issue as well.