Heindals WML Questions
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.
Heindals WML Questions
Hello,
Is it possible to check the "terrain type" of a coordinate and than save it in a variable? I need this for a random encounter, with changing maps.
I haven't found anything so far within the wiki and I'd appreciate your help.
Kind regards
Heindal
Is it possible to check the "terrain type" of a coordinate and than save it in a variable? I need this for a random encounter, with changing maps.
I haven't found anything so far within the wiki and I'd appreciate your help.
Kind regards
Heindal
Last edited by Heindal on October 22nd, 2012, 5:54 pm, edited 1 time in total.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Re: Check Terrain Type of a changing coordinate
Try something like:
Code: Select all
[store_locations]
x,y=$x1,$y1
variable=stored_terrain
[/store_locations]
Author of Antar, Son of Rheor ( SP Campaign) | Development Thread + Feedback Thread + Replays of ASoR
Re: Check Terrain Type of a changing coordinate
Holy WML knowledge gap . This should work fine.
Thank you very much Adamant14 .
Thank you very much Adamant14 .
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Re: Check Terrain Type of a changing coordinate
Well, it doesn't work. I don't know what I'm doing wrong. The idea sounds simple.
Select the x,y coordinate of the herounit, check the terraintype and than call an encounter (each type of terrain is a scenario) that is based on the terrain type, for example a scenario within a desert, when the hero stands on a desert field.
My main problem is that the saved varriable "terrain" is always empty. I tried different approaches with filters, adding the hero id it won't work. Can anybody give me an advice?
Select the x,y coordinate of the herounit, check the terraintype and than call an encounter (each type of terrain is a scenario) that is based on the terrain type, for example a scenario within a desert, when the hero stands on a desert field.
My main problem is that the saved varriable "terrain" is always empty. I tried different approaches with filters, adding the hero id it won't work. Can anybody give me an advice?
Code: Select all
#define CALLENCOUNTER
[store_unit]
[filter]
id=you
[/filter]
variable=younit
[/store_unit]
[set_variable]
name=XHEROSPAWN
value=$younit.x
[/set_variable]
[set_variable]
name=YHEROSPAWN
value=$younit.y
[/set_variable]
{CLEAR_VARIABLE younit}
[store_time_of_day]
x,y=$XHEROSPAWN,$YHEROSPAWN
variable=daytime
[/store_time_of_day]
[store_locations]
x,y=$XHEROSPAWN,$YHEROSPAWN
variable=terrain
[/store_locations]
[if]
[variable]
name=terrain
equals=Dd^Dc
[/variable]
[or]
[variable]
name=terrain
equals=Dd^Do
[/variable]
[/or]
[or]
[variable]
name=terrain
equals=Hd
[/variable]
[/or]
[or]
[variable]
name=terrain
equals=Md
[/variable]
[/or]
[then]
{CONTINUE Encounter5}
[/then]
[/if]
#enddef
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Re: Check Terrain Type of a changing coordinate
terrain.terrain
It stores terrain inside the container variable
I would avoid naming a location variable as terrain to prevent this confusion, e.g. my_location.terrain
It stores terrain inside the container variable
I would avoid naming a location variable as terrain to prevent this confusion, e.g. my_location.terrain
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: Check Terrain Type of a changing coordinate
As a shortcut, you might remove [store_locations] and use [have_location].
Code: Select all
[if]
[have_location]
x,y=$XHEROSPAWN,$YHEROSPAWN
terrain=Dd^Dc,Dd^Do,Hd,Md
[/have_location]
[then]
# ...
--Kernigh http://www.wesnoth.org/wiki/User:Kernigh
Re: Check Terrain Type of a changing coordinate
Thanks both of you! It works fine now. No I need to look up some terrain variables, but thanks to have location I can make a comma separated list, which should work fine and reduce the code. If anyone is interested in the code for the random encounter or the maps, I can post them later. It will be published in the new version of Strange Legacy.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Re: Heindals WML Questions
I have two other questions. At the moment I'm working on two macros.
The first macro should be simple range test, that will allows to use a attack, spell or ability over a greater range. The parts of the macro are placed within a spelloption and should test if the target is in range. At the moment it has no effect for some reason. The else part is buggy, but it seems that I'm blind. I can't find a mistake in the definition.
The second macro should place a trap (or a move to event) in a scenario.
It doesn't seem to work, the macro so far just places the label but not the event.
I tried two different approaches to solve the problem. I used $x1/$y1 and a random identifier togehter with trapx/trapy to define each coordinate as a unique variable. When using trapx/trapy + an identifier just the first trap seems to work when placing the second, it will have the second placed traps has the effect of two traps, while the first one is disarmed. $x1/$y1 each creature moving will be hurt by any placed trap. Any idea what's wrong with it?
The first macro should be simple range test, that will allows to use a attack, spell or ability over a greater range. The parts of the macro are placed within a spelloption and should test if the target is in range. At the moment it has no effect for some reason. The else part is buggy, but it seems that I'm blind. I can't find a mistake in the definition.
Spoiler:
The second macro should place a trap (or a move to event) in a scenario.
Spoiler:
It doesn't seem to work, the macro so far just places the label but not the event.
I tried two different approaches to solve the problem. I used $x1/$y1 and a random identifier togehter with trapx/trapy to define each coordinate as a unique variable. When using trapx/trapy + an identifier just the first trap seems to work when placing the second, it will have the second placed traps has the effect of two traps, while the first one is disarmed. $x1/$y1 each creature moving will be hurt by any placed trap. Any idea what's wrong with it?
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Re: Heindals WML Questions
I'm assuming that it should beCode: Select all
[set_variable] name=texty value=$firer.y [/set_variable]
testy
, not texty
.Co-Creator of The Fellowship of the Clay (BfW 1.10) ~~ Maintainer of the German Code of Conduct
How to isolate problematic WML code ~~ WML error messages and their reasons
How to isolate problematic WML code ~~ WML error messages and their reasons
Re: Heindals WML Questions
you need to learn to debug your code.
using :inspect (you have to enable debug mode, see http://wiki.wesnoth.org/CommandMode) would have revealed the variable mismatch (testx vs. textx).
if you're interested in certain variables directly within your code use [inspect]. it's also sometimes helpful to display messages to see what parts of your code are actually evaluated. you can use [message] or stick to the error macro http://www.wesnoth.org/macro-reference. ... -utils.cfg (just displays message in in-game chat and you don't have to discard lots of message windows).
your way to calculate the distance seems quite complicated, maybe something like that might help: http://forums.wesnoth.org/viewtopic.php ... 08#p481119
using :inspect (you have to enable debug mode, see http://wiki.wesnoth.org/CommandMode) would have revealed the variable mismatch (testx vs. textx).
if you're interested in certain variables directly within your code use [inspect]. it's also sometimes helpful to display messages to see what parts of your code are actually evaluated. you can use [message] or stick to the error macro http://www.wesnoth.org/macro-reference. ... -utils.cfg (just displays message in in-game chat and you don't have to discard lots of message windows).
your way to calculate the distance seems quite complicated, maybe something like that might help: http://forums.wesnoth.org/viewtopic.php ... 08#p481119
- pyrophorus
- Posts: 533
- Joined: December 1st, 2010, 12:54 pm
Re: Heindals WML Questions
Hi !
Why not this to test the range ?
As for the trap event which don't work, did you checked 'delayed_variable_substitution=no' ?
HTH
Why not this to test the range ?
Code: Select all
[have_unit]
id=$firer.id
[filter_location]
x,y=$x1,$y1
radius=$range
[/filter_location]
count=1
[/have_unit]
HTH
HowTos: WML filtering, WML variables
Re: Heindals WML Questions
Thanks for your replies, as soon as I have time and motivation I will test all the proposals.
I'm sorry for not using debugging, I'm still using the game itself as validator.
I'm sorry for not using debugging, I'm still using the game itself as validator.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Re: Heindals WML Questions
Thanks for your answers, I could solve both problems.
Pyrophorus posted solution for range works fine.
I also placed 'delayed_variable_substitution=no' in the event tag, where the map is created.
It works fine now! Thanks to you I could finish my work on "Dungeons of Wesnoth".
Pyrophorus posted solution for range works fine.
I also placed 'delayed_variable_substitution=no' in the event tag, where the map is created.
It works fine now! Thanks to you I could finish my work on "Dungeons of Wesnoth".
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Game Crash
Its me again:
I made several terrain overlays to place them within the map editor. It worked fine for some time but after adding more overlays I can not reload the map editor. I can open the game, but as soon as I try to open the map editor the game crashes. Is there a maximum of terrain overlays for a group?
Can adding terrains cause a crash?
I made several terrain overlays to place them within the map editor. It worked fine for some time but after adding more overlays I can not reload the map editor. I can open the game, but as soon as I try to open the map editor the game crashes. Is there a maximum of terrain overlays for a group?
Can adding terrains cause a crash?
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
- Alarantalara
- Art Contributor
- Posts: 786
- Joined: April 23rd, 2010, 8:17 pm
- Location: Canada
Re: Heindals WML Questions
There is no maximum that I know of (you'd run out of space in "All" first anyway and Archaic Era already has a lot).
It's more likely that you have problems with your ids or terrain strings. Can you post a copy of the file containing all the terrain definitions?
You might also want to try removing other add-ons and trying again. You may have something that conflicts with it in an unusual way. If this is the case, including a list of the add-ons you have installed would also be useful.
It's more likely that you have problems with your ids or terrain strings. Can you post a copy of the file containing all the terrain definitions?
You might also want to try removing other add-ons and trying again. You may have something that conflicts with it in an unusual way. If this is the case, including a list of the add-ons you have installed would also be useful.