Filters help needed
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.
Filters help needed
Hi all, I'm having the some difficulty getting simple filters to work. Here is what I did:
abilities.cfg
some_unit.cfg
I'm using the text popup to highlight units filtered, which shows the above script running for all unit moves as if unfiltered. The wiki did not explain where to put the event so I tossed it in with the unit def above where its [/unit] block terminates. Is there any way to actually Debug scripts in-game?
abilities.cfg
Code: Select all
#define ABILITY_VINEGUARD
[vineguard]
name= _ "vineguard"
description= _ "snags enemies with vines"
affect_self=yes
[/vineguard]
#enddef
Code: Select all
[abilities]
{ABILITY_VINEGUARD}
[/abilities]
...
[event]
name=moveto
first_time_only=no
id=test1
[store_unit]
variable=filtered_units
[filter]
ability=vineguard
[/filter]
[/store_unit]
{FOREACH filtered_units i}
{VARIABLE_OP filtered_units[$i].defense.forest value 0}
[unstore_unit]
variable=filtered_units[$i]
find_vacant=no
text= _ "-16"
{COLOR_HEAL}
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE filtered_units}
[/event]
I'm using the text popup to highlight units filtered, which shows the above script running for all unit moves as if unfiltered. The wiki did not explain where to put the event so I tossed it in with the unit def above where its [/unit] block terminates. Is there any way to actually Debug scripts in-game?
Last edited by Shanjaq on January 15th, 2018, 8:05 am, edited 1 time in total.
Re: Filters. Refuse. To. Work.
ability=vineguard filter doesnt match any units. If you want to use ability= you need to use ability id there, and vineguard doesnt have id. So you need to add id= for your ability.
Re: Filters. Refuse. To. Work.
Ah thanks Ravana, when I added an id=vineguard to the ability it started working (I saw the numbers pop up on every unit with "vineguard" ability.)
So now as I try filtering for units adjacent to units with the vineguard ability, the following filter code causes all units in the map to popup numbers regardless of adjacency, ability or side:
(no changes to the rest of the code apart from changing the unit storage variable to "vineguarded_units")
it seems like the outer filter element is grabbing all units and disregarding the filter_adjacent element? I am trying to follow the "[filter_adjacent]" section of the wiki here:
https://wiki.wesnoth.org/FilterWML/Exam ... r_adjacent.
Also tried like this:
and many other obvious parameters by themselves like "is_enemy=no" with the same result. it's as if [filter_adjacent] does not actually use any of the parameters given? pls help
So now as I try filtering for units adjacent to units with the vineguard ability, the following filter code causes all units in the map to popup numbers regardless of adjacency, ability or side:
Code: Select all
[store_unit]
variable=vineguarded_units
[filter]
[filter_adjacent]
ability=vineguard
is_enemy=no
[/filter_adjacent]
[/filter]
[/store_unit]
it seems like the outer filter element is grabbing all units and disregarding the filter_adjacent element? I am trying to follow the "[filter_adjacent]" section of the wiki here:
https://wiki.wesnoth.org/FilterWML/Exam ... r_adjacent.
Also tried like this:
Code: Select all
[store_unit]
variable=vineguarded_units
[filter_adjacent]
ability=vineguard
[/filter_adjacent]
[/store_unit]
Re: Filters. Refuse. To. Work.
You can save some time (not a lot) by pressing F5 from the main menu. It's a little faster than completely closing and restarting.Shanjaq wrote:I have been booting the game nonstop for hours for days and getting nowhere.
I like to use the inspector window; you can typeShanjaq wrote:Is there any way to actually Debug scripts in-game?
:inspect
after entering debug mode with :debug
to look at variables, and even better is to use [inspect] to make the same window open at any point in the event. Course, that won't help much if you already know that all units are getting stored. Your first code in your second post looks right to me, I'd expect it to store all units that are adjacent to an allied vineguard. Though your event will fire whenever any unit moves, even those that won't end up getting stored.
The last few months have been nothing but one big, painful reminder that TIMTLTW.
Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG
Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG
Re: Filters help needed
I don't know what your ability is intended to actually do, but there's no good way to do it in 1.12; you'll always end up disabling undo when making moves that cause the ability to start/stop affecting a unit. In 1.13 you can do it by using [on_undo] and [on_redo], but it's pretty complicated (see the support ability in UtBS).
Re: Filters help needed
The ability is supposed to be mechanically the same as Leadership, but improve defense for adjacent units on forest tiles instead of boosting their damage.
Re: Filters help needed
Then I think the only way to do it properly is to use events to make sure all attacks of all units receive an invisible weapon special that decreases their CtH against those units. It's a bit icky, but possible.Shanjaq wrote:The ability is supposed to be mechanically the same as Leadership, but improve defense for adjacent units on forest tiles instead of boosting their damage.
Re: Filters help needed
Quick question: Is [filter_adjacent] available in version 1.1.11?
it seems to match all units no matter what I try to filter on, for example:
it seems to match all units no matter what I try to filter on, for example:
Code: Select all
[store_unit]
variable=filtered_units
[filter_adjacent]
ability=vineguard
[/filter_adjacent]
[/store_unit]
Re: Filters help needed
[store_unit] expects [filter].
Re: Filters help needed
is it not possible to store found adjacent units? I searched for "store_unit filter_adjacent" and saw similar being used but it's still matching all units whether a vineguard unit even exists or not:
Code: Select all
[store_unit]
[filter]
[filter_adjacent]
ability=vineguard
[/filter_adjacent]
[/filter]
kill=no
variable=filtered_units
[/store_unit]
Re: Filters help needed
Doing quick test
lua wesnoth.wml_actions.store_unit{variable="_",T.filter{T.filter_adjacent{canrecruit=true}}}
(those adjacent to leaders), only matches those that it should. It seems then that your filter is correct.Re: Filters help needed
ok, I tried replacing my filter with:
and running wesnoth.exe crashed with error:
and it still matched all units no matter how far from the leader. is it possible that placing the filter in a "moveto" event somehow changes the behavior of filters?
full event code:
is it also possible that [filter_adjacent] is not available on 1.1.11 (at least that's what it says in the lower left corner of the main menu?)
also, :debug and :inspect do nothing in any game mode (SP, tutorial, MP-vs-AI, etc.)
Code: Select all
lua wesnoth.wml_actions.store_unit{variable="filtered_units",T.filter{T.filter_adjacent{canrecruit=true}}}
I also tried:error general: Warning: Errors occurred while loading game configuration files: 'Unexpected characters after variable name (expected , or =) at data/units/Monster_Lavaguard.cfg:194 included from data/units.cfg:10 included from data/game.cfg:135
Code: Select all
[store_unit]
[filter]
[filter_adjacent]
canrecruit=true
[/filter_adjacent]
[/filter]
kill=no
variable=filtered_units
[/store_unit]
full event code:
Spoiler:
also, :debug and :inspect do nothing in any game mode (SP, tutorial, MP-vs-AI, etc.)
Re: Filters help needed
That lua line is for debug only, after :debug you can put that to command line - basically allows testing without reloading wesnoth.
For normal code it would be written as
If you somehow did happen to find 1.1.11, then I suggest you instead install something from 1.12 or 1.13.
Your moveto event does not break filters.
For normal code it would be written as
Code: Select all
[store_unit]
variable="_"
[filter]
[filter_adjacent]
canrecruit=yes
[/filter_adjacent]
[/filter]
[/store_unit]
Your moveto event does not break filters.