Changing terrain

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
Fosprey
Posts: 254
Joined: January 25th, 2008, 8:13 am

Changing terrain

Post by Fosprey »

I can`t figure out why this event doesn`t work. It sets the item properly, all the menu work, it takes the gold as it should. But the terrain doesn`t change, i can`t figure out why. This is on dev version 1.7

Code: Select all

[event]
name=turn 1
first_time_only=yes

[set_menu_item]
id=Build
description="Building"
[show_if]
[have_unit]
side=$side_number
x,y=$x1,$y1
type="Peasant"
[filter_location]
terrain="Khr,Gg"
[/filter_location]
[/have_unit]
[/show_if]
[command]
[store_unit]
[filter]
x=$x1
y=$y1
[/filter]
kill=yes
mode=replace
variable=worker
[/store_unit]
[if]
[variable]
name=worker.moves
greater_than=0
[/variable]
[then]

[message]
       speaker="narrator"
       message= _ "`@Do you want to build the Castle?"
[option]
message= _ "Build a Castle. -20 Gold"
[command]
[if]
[variable]
name=gold
greater_than_equal_to=20
[/variable]
[then]
[set_variable]
name=worker.moves
value=0
[/set_variable]
[gold]
side=$side_number
amount=-20
[/gold]
[terrain]
x=$x1
y=$y1
letter="Kh"
replace_if_failed=yes
[/terrain]
[/then]
[/if]
[unstore_unit]
variable=worker
[/unstore_unit]
[/command]
[/option]

[option]
message= _ "Don't Build"
[command]
[unstore_unit]
variable=worker
[/unstore_unit]
[/command]
[/option]
[/message]
[/then]
[else]
[unstore_unit]
variable=worker
[/unstore_unit]
[/else]
[/if]
[/command]
[/set_menu_item]
[/event]
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Changing terrain

Post by zookeeper »

Fosprey wrote:But the terrain doesn`t change, i can`t figure out why.
Of course you can, you've already pinpointed the exact point where the mistake is as far as I can tell. That is, you're using letter= and not terrain=.
Fosprey
Posts: 254
Joined: January 25th, 2008, 8:13 am

Re: Changing terrain

Post by Fosprey »

zookeeper wrote:
Fosprey wrote:But the terrain doesn`t change, i can`t figure out why.
Of course you can, you've already pinpointed the exact point where the mistake is as far as I can tell. That is, you're using letter= and not terrain=.
Thanks for the answer, but as far as i can tell you can use letter instead of terrain, I saw it multiple times in all the building eras i revised. Anyway i tried to change it, but still the same problem

Code: Select all

[event]
name=turn 1
first_time_only=yes

[set_menu_item]
id=Build
description="Building"
[show_if]
[have_unit]
side=$side_number
x,y=$x1,$y1
type="Peasant"
[filter_location]
terrain="Khr,Gg"
[/filter_location]
[/have_unit]
[/show_if]
[command]
[store_unit]
[filter]
x=$x1
y=$y1
[/filter]
kill=yes
mode=replace
variable=worker
[/store_unit]
[if]
[variable]
name=worker.moves
greater_than=0
[/variable]
[then]

[message]
       speaker="narrator"
       message= _ "`@Do you want to build the Castle?"
[option]
message= _ "Build a Castle. -20 Gold"
[command]
[if]
[variable]
name=gold
greater_than_equal_to=20
[/variable]
[then]
[set_variable]
name=worker.moves
value=0
[/set_variable]
[gold]
side=$side_number
amount=-20
[/gold]
[terrain]
x=$x1
y=$y1
terrain="Kh"
replace_if_failed=yes
[/terrain]
[/then]
[/if]
[unstore_unit]
variable=worker
[/unstore_unit]
[/command]
[/option]

[option]
message= _ "Don't Build"
[command]
[unstore_unit]
variable=worker
[/unstore_unit]
[/command]
[/option]
[/message]
[/then]
[else]
[unstore_unit]
variable=worker
[/unstore_unit]
[/else]
[/if]
[/command]
[/set_menu_item]
[/event]
Edit= Yes you were right, changing letter for terrain didn't work first time because it wasn't the only error, the second error there was that using gold as a variable, didn't work, i had to store the gold from the side, give the variable a name, and use that. Thanks for the help
Post Reply