Another basic lua query
Moderator: Forum Moderators
- Spannerbag
- Posts: 780
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: Another basic lua query
Good to know unit context of __cfg, thanks.

When the ***** documentation is helpful...

Thanks for the clarification!
Cheers!
-- Spannerbag
- Spannerbag
- Posts: 780
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: Another basic lua query: syntax query #2
gnombat wrote: ↑Yesterday, 2:54 pm Try this:
Code: Select all
local my_filter = { side = wesnoth.current.side, { "filter_adjacent", { id = target.id } } } my_filter = wml.merge(filter_follower, my_filter, 'append') wesnoth.interface.add_chat_message(wml.tostring(my_filter))

Faffed around for awhile trying to understand why variables were correctly interpreted sometimes but not always.
Don't fully know why but am 99% certain it's my lack of familiarity with lua

Anyway got the following to run without errors -

It even seemed to produce the desired behaviour!

Code: Select all
local filter_follower = wml.get_child(cfg, "filter_follower")
-- Debug
local my_filter = wml.merge(filter_follower, { side = wesnoth.current.side, wml.tag.filter_adjacent { id = target.id } } )
wesnoth.interface.add_chat_message(wml.tostring(my_filter))
local adj_followers = wesnoth.units.find_on_map ( wml.merge(filter_follower, { side = wesnoth.current.side, wml.tag.filter_adjacent { id = target.id } } ) )
append
however it was good to demonstrate that syntax as I'd struggles with that, too. 
With
append
:
Without
Whilst it probably wasn't worth all this effort just to remove a few and
clauses, I've learned a bit more about lua! Thanks to everyone who took the trouble to reply, your time and trouble are greatly appreciated.
Cheers!
-- Spannerbag