Inconsistent results with Terrain_Graphics.

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
BajMic
Posts: 48
Joined: January 24th, 2023, 1:22 am

Inconsistent results with Terrain_Graphics.

Post by BajMic »

Hello,

I am struggling with getting consistent results, with the [terrain_graphics] tag. Specifically, the ones with absolute coordinates. Sometimes I get them to work, sometimes I don't and I can't figure out the pattern. The tutorials from website don't seem to work: https://wiki.wesnoth.org/Terraingraphicswml .

Where is a mistake in the following? All map is tagged instead of one specific tile.

Code: Select all

[terrain_graphics]

	x,y=30,17

        [tile]
		x=0
		y=0
            	set_flag=center, x
        [/tile]

        probability=100

[/terrain_graphics]
Thank you.
User avatar
beetlenaut
Developer
Posts: 2830
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Inconsistent results with Terrain_Graphics.

Post by beetlenaut »

There isn't any [image] here. I don't understand how it could work even some of the time without one.

I would take out set_flag (at least at this point), because that could cause inconsistent results if some other, random [tile]s are placed based on the same flags. (Based on what you have, I suspect that you may not understand what flags do in the first place.)
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Heindal
Posts: 1364
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: Inconsistent results with Terrain_Graphics.

Post by Heindal »

There is an example that can be found in the core data. You should know about these macros and where they can be found.
Usually macros can be found inside of: wesnoth\data\core\macros.

But the terrain macros have an folder of their own which is located here: wesnoth\data\core\terrain-graphics
Here you can find some examples in the new-macros.cfg such as:

Code: Select all

 
 
#define NEW:BASE TERRAIN IMAGESTEM
    # Places {IMAGESTEM}[1-11].png as base tiles. Assumes 72x72 hex-shaped
    # images.

#arg IPF
#endarg

#arg FLAG
    base
#endarg

#arg LAYER
    -1000
#endarg

    [terrain_graphics]
        [tile]
            x,y=0,0
            type={TERRAIN}
            set_no_flag={FLAG}

            [image]
                name={IMAGESTEM}@V.png{IPF}
                variations=";2;3;4;5;6;7;8;9;10;11"
                layer={LAYER}
            [/image]
        [/tile]
    [/terrain_graphics]
#enddef

 
I hope it helps and have fun. And yeah, there should be more examples inside the wiki.
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
BajMic
Posts: 48
Joined: January 24th, 2023, 1:22 am

Re: Inconsistent results with Terrain_Graphics.

Post by BajMic »

What I am doing is I am making a large map of just tags, then I create general rules for images. The work-in-progress result is as on the picture attached.

However, I just discovered that units dissapear behind my images. Hence the next questions:

1. What layer do units occupy?

2. Is it possible to make them occupy higher layer on certain tiles without defining new terrains?
Attachments
Przechwytywanie.PNG
User avatar
beetlenaut
Developer
Posts: 2830
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Inconsistent results with Terrain_Graphics.

Post by beetlenaut »

BajMic wrote: May 25th, 2024, 6:41 am What I am doing is I am making a large map of just tags, then I create general rules for images.
I don't really understand this, so I don't know why you have this problem. Because of this, I don't know if you found the best method of solving it, but I can answer your questions anyway.

1: It is usually 0, but some flying units (bats, for example) are set to layer=60.

2: Yes, but you need to define new units. Bats in SotA do exactly this, so you can look at those unit files to see the easiest way to do it. You can also look at the Wolf Rider to see how to choose an image based on terrain. (The wolf raises its head on water tiles.)
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
BajMic
Posts: 48
Joined: January 24th, 2023, 1:22 am

Re: Inconsistent results with Terrain_Graphics.

Post by BajMic »

Ok. Everything works so far, but what if I wanted to create new types of tiles? Specifically a tile type that places units at layer 1 instead of 0. Is there a specific tutorial for this? I apologize for the lazy question, I finally got lost and confused in the tutorials and all this stuff.
Post Reply