WML trigger action for each Gg^Vov

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
vorwi
Posts: 58
Joined: July 3rd, 2018, 10:11 am

WML trigger action for each Gg^Vov

Post by vorwi »

Hi

My goal is to make big trees to work as villages on my map
but I can't use "village overlay" on big trees cause it make them dissappear

So I came up with solution to put that overlay over grass(Gg^Vov)
and then put image of the big tree like this:

Code: Select all

{PLACE_IMAGE "terrain/forest/great-tree-tile.png" 5 3}
{PLACE_IMAGE "terrain/forest/great-tree.png" 5 2}
I'm not going to do this for each tile by hand
and I couldn't find anything like this via google

Is there anyway to do this something like that:

Code: Select all

[terrain_mask]
	map="custom_map.map"
        [if]
            terrain=Gg^Vov
            [then]
            	{PLACE_IMAGE "terrain/forest/great-tree-tile.png" $x $y}
		{PLACE_IMAGE "terrain/forest/great-tree.png" $x $y-1}
            [/then]
        [/if]
[/terrain_mask]
Thank You
white_haired_uncle
Posts: 1237
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: WML trigger action for each Gg^Vov

Post by white_haired_uncle »

[store_locations] with a terrain filter to an array, then use for/each?
Speak softly, and carry Doombringer.
vorwi
Posts: 58
Joined: July 3rd, 2018, 10:11 am

Re: WML trigger action for each Gg^Vov

Post by vorwi »

white_haired_uncle wrote: September 27th, 2023, 10:56 pm [store_locations] with a terrain filter to an array, then use for/each?
Can I store whole map?


Could You show me your idea with example?
white_haired_uncle
Posts: 1237
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: WML trigger action for each Gg^Vov

Post by white_haired_uncle »

Code: Select all

[store_locations]
        terrain=Gg^Vov
        variable=big_trees
[/store_locations]
[foreach]
    array=big_trees
    [do]
        {PLACE_IMAGE "terrain/forest/great-tree-tile.png" $this_item.x $this_item.y}
        {PLACE_IMAGE "terrain/forest/great-tree.png" $this_item.x $this_item.y-1}
   [/do]
[/foreach]
{CLEAR_VARIABLE big_trees}
Of course, you may need to modify the second PLACE_ITEM line, I can never keep track of where you can use an expression like that and where you need to express it differently.
Speak softly, and carry Doombringer.
vorwi
Posts: 58
Joined: July 3rd, 2018, 10:11 am

Re: WML trigger action for each Gg^Vov

Post by vorwi »

Thanks!
You are amazing!

Now it works

Here's the final result in case someone bumps into this topic with same problem:

Code: Select all

[event]
        name=prestart
        [store_locations]
            terrain=Gg^Vov
            variable=big_trees
        [/store_locations]
        [foreach]
            array=big_trees
            [do]
                [set_variable]
                    name=y_sub_1
                    value=$this_item.y
                    sub=1
                [/set_variable]
                {PLACE_IMAGE "terrain/forest/great-tree-tile.png" $this_item.x $this_item.y}
                {PLACE_IMAGE "terrain/forest/great-tree.png" $this_item.x $y_sub_1}
            [/do]
        [/foreach]
        {CLEAR_VARIABLE big_trees}
        {CLEAR_VARIABLE y_sub_1}
[/event]
one of effects:
SS_2023-09-28_20-40.png
SS_2023-09-28_20-40.png (106.24 KiB) Viewed 3515 times
Post Reply