Replacing terrains

The place to post your WML questions and answers.

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.
Post Reply
mihoshi
Posts: 52
Joined: February 16th, 2008, 10:18 pm

Replacing terrains

Post by mihoshi »

I need to change all terrains on map from one type of another. According to documentation, this should do it:
[event]
name=start
[terrain]
terrain=Chr
[or]
terrain=Ch
[/or]
[/terrain]
[/event]

But it doesn't. Tried other approaches - nothing. Why is it not working and what should I use insted?
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Replacing terrains

Post by zookeeper »

If the wiki is correct and [terrain] does indeed take a SLF, then it's currently in a rather broken/ambiguous state because terrain= is supposed to be a valid key both for [terrain] itself and a SLF.
mihoshi
Posts: 52
Joined: February 16th, 2008, 10:18 pm

Re: Replacing terrains

Post by mihoshi »

Yes, zookeper, it seems same way for me.
It seems that wiki is wrong, and [terrain] doesn't understand anything from SLF. And analysing sources shows the same. Just x and y, or range of x and y, but that's all.

Btw, I found a working solution:

Code: Select all

	[store_locations]
		terrain=C*
		variable=temp_castles
	[/store_locations]
		
	{FOREACH temp_castles i}
		[terrain]
			x=$temp_castles[$i].x
			y=$temp_castles[$i].y
			terrain=Chr
		[/terrain]
	{NEXT i}
As you see, only when I get rid of everyrhing SLF in [terrain] it worked...
mihoshi
Posts: 52
Joined: February 16th, 2008, 10:18 pm

Re: Replacing terrains

Post by mihoshi »

Btw, I'm using this macro that works about as [terrain] should:

Code: Select all

#define TERRAIN RULES TO
	[store_locations]
		{RULES}		
		variable=TERRAIN_TEMP
	[/store_locations]
		
	{FOREACH TERRAIN_TEMP TERRAIN_TEMP_i}
		[terrain]
			x=$TERRAIN_TEMP[$TERRAIN_TEMP_i].x
			y=$TERRAIN_TEMP[$TERRAIN_TEMP_i].y
			terrain={TO}
		[/terrain]
	{NEXT TERRAIN_TEMP_i}
#enddef
Usage:

Code: Select all

	{TERRAIN terrain=C* Chr}

	{TERRAIN (
		x=40
		y=40
		radius=10		
	) Qxu}	
Post Reply