Heindals WML Questions

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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.
User avatar
Heindal
Posts: 895
Joined: August 11th, 2011, 9:25 pm
Location: Germany

Heindals WML Questions

Post by Heindal » July 11th, 2012, 6:48 pm

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
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
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses

User avatar
Adamant14
Posts: 794
Joined: April 24th, 2010, 1:14 pm
Contact:

Re: Check Terrain Type of a changing coordinate

Post by Adamant14 » July 11th, 2012, 7:03 pm

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


Please add your (or some other) campaign to this sites: Guide to UMC Campaigns | Players' Review(s) | Please leave a comment here: WML filtering , WML variables

User avatar
Heindal
Posts: 895
Joined: August 11th, 2011, 9:25 pm
Location: Germany

Re: Check Terrain Type of a changing coordinate

Post by Heindal » July 12th, 2012, 9:10 pm

Holy WML knowledge gap :oops:. This should work fine.

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
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses

User avatar
Heindal
Posts: 895
Joined: August 11th, 2011, 9:25 pm
Location: Germany

Re: Check Terrain Type of a changing coordinate

Post by Heindal » July 16th, 2012, 8:26 pm

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?



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
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses

User avatar
Sapient
Inactive Developer
Posts: 4452
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Check Terrain Type of a changing coordinate

Post by Sapient » July 16th, 2012, 8:59 pm

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
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."

Kernigh
Posts: 107
Joined: February 13th, 2007, 10:21 pm
Location: United States
Contact:

Re: Check Terrain Type of a changing coordinate

Post by Kernigh » July 16th, 2012, 9:13 pm

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]
        # ...

User avatar
Heindal
Posts: 895
Joined: August 11th, 2011, 9:25 pm
Location: Germany

Re: Check Terrain Type of a changing coordinate

Post by Heindal » July 17th, 2012, 5:53 pm

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
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses

User avatar
Heindal
Posts: 895
Joined: August 11th, 2011, 9:25 pm
Location: Germany

Re: Heindals WML Questions

Post by Heindal » October 22nd, 2012, 6:30 pm

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.
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
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses

Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Heindals WML Questions

Post by Ceres » October 22nd, 2012, 8:29 pm

Code: Select all

[set_variable]
  name=texty
  value=$firer.y
[/set_variable]
I'm assuming that it should be testy, not texty.

Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: Heindals WML Questions

Post by Max » October 23rd, 2012, 4:28 am

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

User avatar
pyrophorus
Posts: 513
Joined: December 1st, 2010, 12:54 pm

Re: Heindals WML Questions

Post by pyrophorus » October 23rd, 2012, 7:25 am

Hi !
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]
As for the trap event which don't work, did you checked 'delayed_variable_substitution=no' ?

HTH
Campaign Return to Noelren *** HowTos: WML filtering, WML variables
Please help to to update the Guide to UMC Campaigns

User avatar
Heindal
Posts: 895
Joined: August 11th, 2011, 9:25 pm
Location: Germany

Re: Heindals WML Questions

Post by Heindal » October 23rd, 2012, 4:56 pm

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. :oops:
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses

User avatar
Heindal
Posts: 895
Joined: August 11th, 2011, 9:25 pm
Location: Germany

Re: Heindals WML Questions

Post by Heindal » October 27th, 2012, 12:17 am

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".
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses

User avatar
Heindal
Posts: 895
Joined: August 11th, 2011, 9:25 pm
Location: Germany

Game Crash

Post by Heindal » November 26th, 2012, 10:39 pm

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?
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses

User avatar
Alarantalara
Art Contributor
Posts: 782
Joined: April 23rd, 2010, 8:17 pm
Location: Canada

Re: Heindals WML Questions

Post by Alarantalara » November 26th, 2012, 11:58 pm

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.

Post Reply