Help filtering menu item based on sides unit & location
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.
- Legend_Rider
- Posts: 35
- Joined: June 20th, 2018, 4:51 pm
Help filtering menu item based on sides unit & location
Attempting to create a menu item that only shows up when a unit of the given side is located on specific terrain.
I have accomplished having the menu item show up when clicking on the unit, as well as when clicking on the terrain, but can't seem to combine the two
here's what I'm working with...
Edit: I probably shouldn't be trying to work on WML in the late hours of the night... I just can't get my mind off of it!
I have accomplished having the menu item show up when clicking on the unit, as well as when clicking on the terrain, but can't seem to combine the two
here's what I'm working with...
Code: Select all
# menu item stuffs...
[filter]
unit=$unit.side
x,y=$x1,$y1
[filter_location]
terrain=G*
[/filter_location]
[/filter]
# /menu item stuffs...
Last edited by Legend_Rider on January 21st, 2021, 3:05 pm, edited 1 time in total.
Re: Help filtering menu item based on sides unit & location
Untested:
Code: Select all
[set_menu_item]
[filter]
side=$unit.side
[/filter]
id=test
description=" "
image=" "
[show_if]
[have_unit]
x,y=$x1,$y1
[/have_unit]
[/show_if]
[filter_location]
terrain=G*
[/filter_location]
# stuff
[/set_menu_item]
Re: Help filtering menu item based on sides unit & location
Example https://github.com/ProditorMagnus/Agele ... fg#L39-L69
Code: Select all
[set_menu_item]
[filter_location]
terrain=G*
[filter]
side=4
[/filter]
[/filter_location]
[/set_menu_item]
- Legend_Rider
- Posts: 35
- Joined: June 20th, 2018, 4:51 pm
Re: Help filtering menu item based on sides unit & location
Thank you, Straff!Straff wrote: ↑January 21st, 2021, 10:08 am Untested:Code: Select all
[set_menu_item] [filter] side=$unit.side [/filter] id=test description=" " image=" " [show_if] [have_unit] x,y=$x1,$y1 [/have_unit] [/show_if] [filter_location] terrain=G* [/filter_location] # stuff [/set_menu_item]
That did the trick, it was mostly missing the "show if" tags.
Many thanks!
Last edited by Legend_Rider on January 22nd, 2021, 10:39 pm, edited 1 time in total.
- Legend_Rider
- Posts: 35
- Joined: June 20th, 2018, 4:51 pm
Re: Help filtering menu item based on sides unit & location
Trying to create a similar menu item (to which searching the forums and reading the wiki has only brought me so far.)
Creating a menu item that only shows up when X unit from a side is on X terrain adjacent to Z terrain
Here's one of my many attempts
Edit: clarifications
Creating a menu item that only shows up when X unit from a side is on X terrain adjacent to Z terrain
Here's one of my many attempts
Code: Select all
[set_menu_item]
id=test
description= _ "testing"
[filter]
side=$unit.side # not 100% sure if this is the best/correct key/value for this
[/filter]
[show_if] # only show if the following conditions are met?
[have_unit] # if there is a unit
unit=$unit.side # unit on your side? (idk if it's the right key, tested other keys to no avail)
[filter_location]
terrain=K*
[/filter_location]
[filter_adjacent_location]
terrain=C*
[/filter_adjacent_location]
[/have_unit]
[/show_if]
[command] # a basic option to test the menu
[message]
side_for=$side_number # is this actually necessary? haven't tested it
speaker=narrator
[option]
message= _ "Cancel"
speaker=narrator
[/option]
[/message]
[/command]
[/set_menu_item]
Last edited by Legend_Rider on January 24th, 2021, 10:56 pm, edited 1 time in total.
Re: Help filtering menu item based on sides unit & location
Not sure what you need the side thing for.
Try the following and see if it's what you want:
Edit:
If it's for MP then use
Try the following and see if it's what you want:
Code: Select all
[set_menu_item]
id=test
description= _ "testing"
[show_if]
[have_unit] # if there is a unit
x,y=$x1,$y1
#side=1 # Set the side explicitly, or leave out if it applies to all sides.
#side=$side_number
[filter_location]
terrain=K*
[filter_adjacent_location]
terrain=C*
[/filter_adjacent_location]
[/filter_location]
[/have_unit]
[/show_if]
[command] # a basic option to test the menu
[message]
speaker=$unit.id
message= _ "Hi"
[/message]
[/command]
[/set_menu_item]
If it's for MP then use
side=$side_number
- Legend_Rider
- Posts: 35
- Joined: June 20th, 2018, 4:51 pm
Re: Help filtering menu item based on sides unit & location
Thank you vghetto!vghetto wrote: ↑January 23rd, 2021, 7:01 amEdit:Code: Select all
[set_menu_item] id=test description= _ "testing" [show_if] [have_unit] # if there is a unit x,y=$x1,$y1 #side=1 # Set the side explicitly, or leave out if it applies to all sides. #side=$side_number [filter_location] terrain=K* [filter_adjacent_location] terrain=C* [/filter_adjacent_location] [/filter_location] [/have_unit] [/show_if] [command] # a basic option to test the menu [message] speaker=$unit.id message= _ "Hi" [/message] [/command] [/set_menu_item]
If it's for MP then useside=$side_number
It is for MP use, (forgot to specify, sorry)
This solved my little puzzle.
Only thing I need to do now is figure out how to set the menu to show up adjacent to the unit rather than on the unit.
Re: Help filtering menu item based on sides unit & location
The menu shows up where you right click. It is unclear to me what you'd like to do exactly. Could you clarify?Legend_Rider wrote: ↑January 24th, 2021, 10:53 pm Only thing I need to do now is figure out how to set the menu to show up adjacent to the unit rather than on the unit.
- Legend_Rider
- Posts: 35
- Joined: June 20th, 2018, 4:51 pm
Re: Help filtering menu item based on sides unit & location
As of right now, the context menu shows the option when you have your mouse over the unit on K* terrain, I am working to make the menu show up when you have your mouse over C* terrain and there’s an adjacent unit on K* terrain.
I hope that clarifies.
I hope that clarifies.
Re: Help filtering menu item based on sides unit & location
I didn't test this, but give it a try.
Code: Select all
[set_menu_item]
id=test
description= _ "testing"
[show_if]
[have_unit] # if there is a unit
x,y=$x1,$y1
side=$side_number
[filter_location]
terrain=C*
[filter_adjacent_location]
terrain=K*
[filter]
[/filter]
[/filter_adjacent_location]
[/filter_location]
[/have_unit]
[/show_if]
[command] # a basic option to test the menu
[message]
speaker=$unit.id
message= _ "Hi"
[/message]
[/command]
[/set_menu_item]
Re: Help filtering menu item based on sides unit & location
Should there be a unit on the C* hex, or should the C* hex be empty?
- Legend_Rider
- Posts: 35
- Joined: June 20th, 2018, 4:51 pm
Re: Help filtering menu item based on sides unit & location
I’ll give it a try when I can, the C* hex should be empty.
Whoops, trying to navigate the website on mobile for the first time
I kinda made an oopsie
Whoops, trying to navigate the website on mobile for the first time
I kinda made an oopsie
Last edited by Legend_Rider on January 25th, 2021, 7:17 pm, edited 1 time in total.
- Legend_Rider
- Posts: 35
- Joined: June 20th, 2018, 4:51 pm
Re: Help filtering menu item based on sides unit & location
I’ll give it a try when I canvghetto wrote: ↑January 25th, 2021, 5:36 pm I didn't test this, but give it a try.
Code: Select all
[set_menu_item] id=test description= _ "testing" [show_if] [have_unit] # if there is a unit x,y=$x1,$y1 side=$side_number [filter_location] terrain=C* [filter_adjacent_location] terrain=K* [filter] [/filter] [/filter_adjacent_location] [/filter_location] [/have_unit] [/show_if] [command] # a basic option to test the menu [message] speaker=$unit.id message= _ "Hi" [/message] [/command] [/set_menu_item]
the C* hex should be empty.
Re: Help filtering menu item based on sides unit & location
Ah, then my example won't do what you want.
This might, I didn't test this either
This might, I didn't test this either
Code: Select all
[set_menu_item]
id=test
description= _ "testing"
[show_if]
[have_location]
x,y=$x1,$y1
terrain=C*
[not]
[filter]
[/filter]
[/not]
[filter_adjacent_location]
terrain=K*
[filter]
[/filter]
[/filter_adjacent_location]
[/have_location]
[/show_if]
[command] # a basic option to test the menu
[message]
speaker=$unit.id
message= _ "Hi"
[/message]
[/command]
[/set_menu_item]
- Legend_Rider
- Posts: 35
- Joined: June 20th, 2018, 4:51 pm
Re: Help filtering menu item based on sides unit & location
That did it!!vghetto wrote: ↑January 25th, 2021, 7:37 pm Ah, then my example won't do what you want.
This might, I didn't test this eitherCode: Select all
[set_menu_item] id=test description= _ "testing" [show_if] [have_location] x,y=$x1,$y1 terrain=C* [not] [filter] [/filter] [/not] [filter_adjacent_location] terrain=K* [filter] [/filter] [/filter_adjacent_location] [/have_location] [/show_if] [command] # a basic option to test the menu [message] speaker=$unit.id message= _ "Hi" [/message] [/command] [/set_menu_item]
Thanks a bundle!
May I ask how the "empty" [filter] tags work?
something I've seen before but don't fully understand
Edit: as a side note, I did add a way that limits the menu to only show when it's your unit on the terrain.
Because I'm using village as the terrain, it was very simple to do using "owner_side=$side_number"
Last edited by Legend_Rider on January 28th, 2021, 2:13 am, edited 3 times in total.