Quantcast
Channel: The Battle for Wesnoth Forums
Viewing all articles
Browse latest Browse all 1496

Lua Labs • Re: Teleport Function

$
0
0
:D I HAVE A MAJOR ANNOUNCEMENT TO MAKE! :D

Since no one was capable of creating a code to do such a thing, I was using the lousy alternative to teleport more than one unit: animate pre_teleport flag, hide units, teleport them with animate=no, unhide and animate post_teleport flag. :geek:

The problem was that when I unhide the units, sometimes (not always) they appear before displaying the animation - and that bothered me! :x A LOT! :x

So I decided to take a look at the code of the [unhide_unit] tag. And I realized there was a [redraw] tag in it. Look...

Code:

function wml_actions.unhide_unit(cfg)for i,u in ipairs(wesnoth.units.find_on_map(cfg)) dou.hidden = falseendwml_actions.redraw {}           #HERE!end
And THAT was the problem! The screen is redraw and sometimes the units appear before the animation. :idea: So I copied the code and removed the [redraw]...

Code:

function wesnoth.wml_actions.el_unhide_unit(cfg)for i,u in ipairs(wesnoth.units.find_on_map(cfg)) dou.hidden = falseendend
And it worked! ^_^ Smooth like the teleport tag. Take a look at the whole macro using the [el_unhide_unit]... (I used another macros)

Code:

#define TELEPORT_3_UNITS X Y ONE X1 Y1 TWO X2 Y2 THREE X3 Y3    {ANIMATE_UNIT id={ONE} pre_teleport {ANIMATE id={TWO} pre_teleport {ANIMATE id={THREE} pre_teleport ()}}}    [hide_unit]        id={ONE},{TWO},{THREE}    [/hide_unit]    {TELEPORT id={ONE} {X1} {Y1} no}    {TELEPORT id={TWO} {X2} {Y2} no}    {TELEPORT id={THREE} {X3} {Y3} no}    {SCROLL_TO {X} {Y}}    [el_unhide_unit]        id={ONE},{TWO},{THREE}    [/el_unhide_unit]    {ANIMATE_UNIT id={ONE} post_teleport {ANIMATE id={TWO} post_teleport {ANIMATE id={THREE} post_teleport ()}}}#enddef
:eng: We need to scroll before unhiding them; otherwise the scroll will redraw the screen.

Statistics: Posted by Saizo-Luz — Today, 11:16 am



Viewing all articles
Browse latest Browse all 1496

Trending Articles