How to use HIGHLIGHT_IMAGE

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
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

How to use HIGHLIGHT_IMAGE

Post by Helmet »

I can't get HIGHLIGHT_IMAGE to work.

In my scenario-in-progress, I place a boat on the map at some point, and I want it to flash to draw the player's attention to it. The x,y coordinates are the location of the boat, I'm sure, but the macro requires two other values.

What variable goes into image?

What variable goes into the last spot? Do I put a 0 if there is no item on that hex? If there is an item, how would I enter it for BACKGROUND_VALUE?

If {IMAGE} is a macro within a macro, where is the code located? I checked the macro folder and examined the cfg files that seemed possible locations, but didn't find it.

Here is the code for HIGHLIGHT_IMAGE. Thanks.

Code: Select all

#define HIGHLIGHT_IMAGE X Y IMAGE BACKGROUND_VALUE
    # Scrolls to the given location, blinks the given image in and out a few
    # times, and then leaves the image in place. Use this to pinpoint an
    # important location to the player. If there's an existing [item] on the
    # location, specify it as the BACKGROUND_VALUE or else it'll get lost
    # during the blinking.
    [scroll_to]
        x,y={X},{Y}
        check_fogged=no
    [/scroll_to]

    [repeat]
        times=3
        [do]
            [item]
                x,y={X},{Y}
                halo={IMAGE}
            [/item]

            [redraw][/redraw]

            [delay]
                time=300
            [/delay]

            [remove_item]
                x,y={X},{Y}
            [/remove_item]

            [item]
                x,y={X},{Y}
                image={BACKGROUND_VALUE}
            [/item]

            [redraw][/redraw]

            [delay]
                time=300
            [/delay]
        [/do]
    [/repeat]

    [item]
        x,y={X},{Y}
        image={IMAGE}
    [/item]

    [redraw][/redraw]
#enddef
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Pilauli
Posts: 115
Joined: August 18th, 2020, 12:56 pm

Re: How to use HIGHLIGHT_IMAGE

Post by Pilauli »

Relevant wiki page: https://wiki.wesnoth.org/PreprocessorRef

Relevant example, from the first scenario of HttT:

Code: Select all

        {HIGHLIGHT_IMAGE 1 1 scenery/signpost.png ()}
1 and 1 are the x and y coordinates, of course, and "scenery/signpost.png" is the image that it highlights. Then the () seems to be an empty argument, to set BACKGROUND_VALUE to nothing.

{X} in the function substitutes in the value that you put in place of X when you call the function, and {IMAGE} represents whatever you write in the IMAGE slot, and so on. So if you replace that line in the HttT scenario with this block of code (made by taking the body of the macro and substituting in all the arguments), it should do exactly the same thing as that macro call does.

Code: Select all

    [scroll_to]
        x,y=1,1
        check_fogged=no
    [/scroll_to]

    [repeat]
        times=3
        [do]
            [item]
                x,y=1,1
                halo=scenery/signpost.png
            [/item]

            [redraw][/redraw]

            [delay]
                time=300
            [/delay]

            [remove_item]
                x,y=1,1
            [/remove_item]

            [item]
                x,y=1,1
                image=()
            [/item]

            [redraw][/redraw]

            [delay]
                time=300
            [/delay]
        [/do]
    [/repeat]

    [item]
        x,y=1,1
        image=scenery/signpost.png
    [/item]

    [redraw][/redraw]
I hope this helps!
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: How to use HIGHLIGHT_IMAGE

Post by Helmet »

It worked! Thanks.

It's not as bright as I expected. Moving the boat one hex might be more noticeable. Hm.

HttT was a great campaign. I barely won that amazing last scenario; it took me a few tries. I don't think it's a spoiler to state that the ultimate death animation was brilliant. I forgot that the signpost flashed in the first scenario of HttT. I should start making notes when I play a campaign, so I'll know where to look for code examples.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Post Reply