Count units on a side?
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.
- LordAwsomeness
- Posts: 203
- Joined: August 12th, 2013, 2:20 pm
- Location: U.S.A.
Count units on a side?
is there a way to count the units on a side? specifically units that have a static effect such as poisoned or slowed?
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
Re: Count units on a side?
Code: Select all
[lua]
code = << wml.variables.foo = #wesnoth.get_units { side=1, wml.tag.filter_wml { wml.tag.status { poisoned='yes' } } } >>
[/lua]
- LordAwsomeness
- Posts: 203
- Joined: August 12th, 2013, 2:20 pm
- Location: U.S.A.
Re: Count units on a side?
I am unfamiliar with integrating lua into wml. do I need to just copy and paste that lua syntax or do I have to do something more?josteph wrote: ↑October 16th, 2019, 3:30 amand then access the WML variable $foo.Code: Select all
[lua] wml.variables.foo = #wesnoth.get_units { side=1, wml.tag.filter_wml { wml.tag.status { poisoned='yes' } } } [/lua]
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
Re: Count units on a side?
You can't just paste lua syntax into WML, you have to wrap it in [lua] tags. [lua] tags are ActionWML and can be used wherever ActionWML is allowed, like inside events and menu items and so on.
I edited the previous post to correct a syntax error, make sure to use the new version.
https://wiki.wesnoth.org/LuaWML#The_.5Blua.5D_tag
I edited the previous post to correct a syntax error, make sure to use the new version.
https://wiki.wesnoth.org/LuaWML#The_.5Blua.5D_tag
Re: Count units on a side?
You can store units in WML as well and check length.
Also, filter_wml is not needed for status anymore since 1.12 I think.
Also, filter_wml is not needed for status anymore since 1.12 I think.
- LordAwsomeness
- Posts: 203
- Joined: August 12th, 2013, 2:20 pm
- Location: U.S.A.
Re: Count units on a side?
oh interesting. what would I use to check the wml instead of filter wml?
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
Re: Count units on a side?
status: (Version 1.13.0 and later only) matches if the unit has the specified status active. This can be a comma-separated list, in which case the unit will match as long as it has one of the listed statuses active