advancement filter query
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.
- Spannerbag
- Posts: 539
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
advancement filter query
Hi,
Edit: just tried the hack below and it seems to work so I have that as a backstop
I have some custom AMLAs just wondered if there's an easier way than below to do what I want?
Originally I wanted to allow/enable the advancement when a specific unit variable=1 or always for a specific unit, namely:
This seems to work fine.
However me being me I have added a few more features and now need to test for greater_than.
I tried:
and get an error when I load the campaign. As the variable can only (so far) be 0,1 or 2 I suppose I could use:
However there must (I guess) be a more general form of testing this variable but I can't seem to find the relevant documentation?
Any suggestions?
Cheers!
-- Spannerbag
Edit: just tried the hack below and it seems to work so I have that as a backstop
I have some custom AMLAs just wondered if there's an easier way than below to do what I want?
Originally I wanted to allow/enable the advancement when a specific unit variable=1 or always for a specific unit, namely:
Code: Select all
[advancement]
[filter]
id=Magnus
[or]
[filter_wml]
[variables]
cascade=1
[/variables]
[/filter_wml]
[/or]
[/filter]
However me being me I have added a few more features and now need to test for greater_than.
I tried:
Code: Select all
[advancement]
[filter]
id=Magnus
[or]
[filter_wml]
[variables]
cascade>1 # ">" not "="
[/variables]
[/filter_wml]
[/or]
[/filter]
Code: Select all
[advancement]
[filter]
id=Magnus
[or]
[filter_wml]
[variables]
cascade=1
[/variables]
[/filter_wml]
[/or]
[or]
[filter_wml]
[variables]
cascade=2
[/variables]
[/filter_wml]
[/or]
[/filter]
Any suggestions?
Cheers!
-- Spannerbag
Last edited by Spannerbag on February 25th, 2023, 11:22 pm, edited 1 time in total.
Re: advancement filter query
Can yu use ?
Code: Select all
require_amla
- Spannerbag
- Posts: 539
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: advancement filter query
I use that as well
Edit - best explain, the cascade variable acts as an on/off switch;
=0 -> off
=1 -> level 1 enabled
=2 -> level 2 enabled
Issue is that with level 2 enabled I need to allow a unit that has not yet taken level 1 to do so, so it isn't level 2 that's the problem but rather level 1.
Or, to put it another way, whether or not level 2 is available depends on that unit having level 1 plus level 2 being generally available.
However when level 2 is available if a unit has not yet obtained level one then only level one should be available for that unit.
require_amla forces the unit to take level 2 only when level 1 is first obtained but for level 1 I need to check if level 1 or level 2 are generally available (yes, I know that there are other ways to do this but I'd rather use this way if possible as there's loads of gnarly code already in this campaign ).
Cheers!
-- Spannerbag
Re: advancement filter query
Yes, that couldn't possibly work - WML is fundamentally a very simple language and it has no idea what symbols likeSpannerbag wrote: ↑February 25th, 2023, 10:59 pm I tried:
and get an error when I load the campaign.Code: Select all
[advancement] [filter] id=Magnus [or] [filter_wml] [variables] cascade>1 # ">" not "=" [/variables] [/filter_wml] [/or] [/filter]
<
or >
mean. (These are, in fact, invalid syntax.)I haven't tested it, but couldn't you use
[variable]
, together with greater_than
?Re: advancement filter query
Code: Select all
[variable]
name=unit.variables.cascade
greather_than=1
[variable]
unit
you can [store_unit]
on another variable if necessary)But this is conditionalWML, and not StandardUnitFilter, so it must be used in another way, for example with an event.
Re: advancement filter query
There is cleaner way to use formulas now but old way should still work "if(($this_unit.variables.AE_imp_rune_end -1 > -1), 1, 0)"
-1 was important to include because otherwise game crashed if variable was missing.
-1 was important to include because otherwise game crashed if variable was missing.
- Spannerbag
- Posts: 539
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: advancement filter query
I'll try that but I assumed as textual rather than symbolic notation worked for equality (i.e. "=" not "equals") then for consistency I should use ">" not "greater_than". However "=" and ">" work in formula syntax so I thought it worth a shot here.gnombat wrote: ↑February 26th, 2023, 1:06 amYes, that couldn't possibly work - WML is fundamentally a very simple language and it has no idea what symbols likeSpannerbag wrote: ↑February 25th, 2023, 10:59 pm I tried:
and get an error when I load the campaign.Code: Select all
... cascade>1 # ">" not "=" ...
<
or>
mean. (These are, in fact, invalid syntax.)
I haven't tested it, but couldn't you use[variable]
, together withgreater_than
?
Bear in mind I'm working inside a
[filter]
inside [advancement]
, so I don't have access to [filter_condition]
(I assume, haven't tried tbh) and thereby [variable]
.Thanks for the reply.
Cheers,
-- Spannerbag
- Spannerbag
- Posts: 539
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: advancement filter query
Thanks for the input, but as you say I I can't use this insideToranks wrote: ↑February 26th, 2023, 8:46 am(instead of useCode: Select all
[variable] name=unit.variables.cascade greather_than=1 [variable]
unit
you can[store_unit]
on another variable if necessary)
But this is conditionalWML, and not StandardUnitFilter, so it must be used in another way, for example with an event.
[advancement][filter]
?I'd need
[filter_condition]
- which I haven't tried but might be recognised by [advancement]
.I already have a plethora of weird and wonderful events scattered about - I'm amazed the engine hasn't had a nervous breakdown!
Thanks for replying.
Cheers,
-- Spannerbag
- Spannerbag
- Posts: 539
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: advancement filter query *FIXED*
Thanks, I'll try it out.
...
Y'know, I really should properly read the documentation. Ive used formulas in
[filter]
but missed something.The following worked exactly as I wanted and is generalised, so if I extend this advancement even further (as is likely when I get round to AfterEI v2) this code hopefully will work unchanged. Thanks for giving me a prod to revisit formulas!
Code: Select all
[advancement]
[filter]
id=Magnus
[or]
formula="wml_vars.cascade > 0"
[/or]
[/filter]
Code: Select all
[advancement]
[filter]
id=Magnus
[or]
formula="wml_vars.cascade > 1"
[/or]
[/filter]
-- Spannerbag