map:find_in_radius and wml.parsed

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

Post Reply
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2337
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

map:find_in_radius and wml.parsed

Post by Lord-Knightmare »

Hello, in my quest to patch up 1.15 World Conquest, I have stumbled upon these two deprecation warnings (the last 2 left).

Code: Select all

Invalid WML found: map:get_tiles_radius has been deprecated indefinitely.; The filter is now the last parameter, instead of the radius (Note: You should use map:find_in_radius instead in new code)
Invalid WML found: wml.parsed has been deprecated indefinitely.; Since vconfigs are not supported outside of the game kernel, this function is redundant and will be removed from plugin and map generation contexts. It will continue to work in the game kernel. (Note: You should use (no replacement) instead in new code)
I have checked the wiki but I have found no documentation related to these things and the warning messages don't really seem helpful.
On the topic of map:get_tiles_radius --> map:find_in_radius, I did convert all instances and moved the radius before the filter, but all it did was completely break World Conquest so I had to revert those changes. Thus, any example code regarding the the usage of map:find_in_radius and the procedure for dealing with the wml.parsed one is appreciated.

My current progress on patching bugs can be found here.
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
User avatar
Celtic_Minstrel
Developer
Posts: 2158
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: map:find_in_radius and wml.parsed

Post by Celtic_Minstrel »

What you did for get_tiles_radius should have been the correct change. Did it give an error message? You can see it either in the log or in the Lua console. (Note: You can only open the Lua console by adding a gui.show_lua_console() call somewhere in the map generation script; might also need to wrap something in a pcall if an error prevents the console show command from being reached.)

The procedure for wml.parsed is less clear. In plugins it doesn't make sense to use vconfigs, because there's no such thing as game variables, so the correct procedure would be to either remove it (just use the config directly) or to use wml.interpolate (which is the same but takes the variables as an extra argument instead of using the game variables). That used to be true in map generation, but at some point gfgtdf added the ability to read game variables in the map generation script, allowing the generation to depend on options or on outcomes from earlier scenarios. So the correct solution might actually be to undeprecate it for map generation scripts.
Last edited by Celtic_Minstrel on May 1st, 2021, 11:25 pm, edited 1 time in total.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2337
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: map:find_in_radius and wml.parsed

Post by Lord-Knightmare »

Celtic_Minstrel wrote: April 22nd, 2021, 4:03 am What you did for `get_tiles_radius` should have been the correct change. Did it give an error message? You can see it either in the log or in the Lua console. (Note: You can only open the Lua console by adding a `gui.show_lua_console()` call somewhere in the map generation script; might also need to wrap something in a pcall if an error prevents the console show command from being reached.)
The procedure for `wml.parsed` is less clear. In plugins it doesn't make sense to use vconfigs, because there's no such thing as game variables, so the correct procedure would be to either remove it (just use the config directly) or to use `wml.interpolate` (which is the same but takes the variables as an extra argument instead of using the game variables). That used to be true in map generation, but at some point gfgtdf added the ability to read game variables in the map generation script, allowing the generation to depend on options or on outcomes from earlier scenarios. So the correct solution might actually be to undeprecate it for map generation scripts.
This is what I am concerned with right now. I guess un-deprecating it would solve this issue and make world conquest playable again.
Last edited by Lord-Knightmare on April 22nd, 2021, 2:20 pm, edited 1 time in total.
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2337
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: map:find_in_radius and wml.parsed

Post by Lord-Knightmare »

Lord-Knightmare wrote: April 22nd, 2021, 2:10 pm
What you did for `get_tiles_radius` should have been the correct change. Did it give an error message? You can see it either in the log or in the Lua console. (Note: You can only open the Lua console by adding a `gui.show_lua_console()` call somewhere in the map generation script; might also need to wrap something in a pcall if an error prevents the console show command from being reached.)
I finally got passed this. Turns out I forgot to enclose the filters inside a parenthesis. This is FIXED.
Nevermind. I had the directory wrong in my add-on version on fixing it, I got...

Code: Select all

...s/World_Conquest/lua/map/postgeneration_utils/events.lua:114: ')' expected near ','	stack traceback:
	[string ""]:7: in function <[string ""]:7>
	[C]: in field 'dofile'
	~add-ons/World_Conquest/lua/map/wct_map_generator.lua:37: in upvalue 'run_postgeneration'
	~add-ons/World_Conquest/lua/map/wct_map_generator.lua:74: in local 'mapgen_func'
	~add-ons/World_Conquest/lua/map/main.lua:134: in function '.wc_ii_generate_scenario'
	(...tail calls...)
	[C]: in function '.xpcall'
	[string ""]:7: in main chunk
nil
20210422 20:17:07 error mapgen: No castle location found, for 3 players aborting. 
...s/World_Conquest/lua/map/postgeneration_utils/events.lua:114: ')' expected near ','	stack traceback:
	[string ""]:7: in function <[string ""]:7>
	[C]: in field 'dofile'
	~add-ons/World_Conquest/lua/map/wct_map_generator.lua:37: in upvalue 'run_postgeneration'
	~add-ons/World_Conquest/lua/map/wct_map_generator.lua:74: in local 'mapgen_func'
	~add-ons/World_Conquest/lua/map/main.lua:134: in function '.wc_ii_generate_scenario'
	(...tail calls...)
	[C]: in function '.xpcall'
	[string ""]:7: in main chunk
nil
...s/World_Conquest/lua/map/postgeneration_utils/events.lua:114: ')' expected near ','	stack traceback:
	[string ""]:7: in function <[string ""]:7>
	[C]: in field 'dofile'
	~add-ons/World_Conquest/lua/map/wct_map_generator.lua:37: in upvalue 'run_postgeneration'
	~add-ons/World_Conquest/lua/map/wct_map_generator.lua:74: in local 'mapgen_func'
	~add-ons/World_Conquest/lua/map/main.lua:134: in function '.wc_ii_generate_scenario'
	(...tail calls...)
	[C]: in function '.xpcall'
	[string ""]:7: in main chunk
nil
Screenshot 2021-04-22 201746.png
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Soliton
Site Administrator
Posts: 1678
Joined: April 5th, 2005, 3:25 pm
Location: #wesnoth-mp

Re: map:find_in_radius and wml.parsed

Post by Soliton »

The deprecation message lets you guess what the new parameter order is. It's perhaps easy to see if you look at the code:
https://github.com/wesnoth/wesnoth/blob ... #L264-L265

So it should be map:find_in_radius({keep_loc}, 1, wesnoth.map.filter(f.terrain("C*,K*"))).

Just radius and filter got switched around for whatever reason.
"If gameplay requires it, they can be made to live on Venus." -- scott
Post Reply