WML [move_unit] to other unit's current position

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
Kadel_007
Posts: 16
Joined: November 21st, 2021, 9:14 pm

WML [move_unit] to other unit's current position

Post by Kadel_007 »

I have an issue: I want to move the unit to another's unit using [move_unit], but I don't know how to retrieve the unit's location. How should I do it?

Code:

Code: Select all

[move_unit]
id = Unit_Id
force_scroll=yes
to_x=AnotherUnit_Id.x #  how to retrieve another's unit x ?
to_y=AnotherUnit_Id.y # how to retrieve another's unit y ?
[/move_unit]
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: WML [move_unit] to other unit's current position

Post by Pentarctagon »

[store_unit] potentially?
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
Kadel_007
Posts: 16
Joined: November 21st, 2021, 9:14 pm

Re: WML [move_unit] to other unit's current position

Post by Kadel_007 »

Well, I checked the syntax.

https://wiki.wesnoth.org/InternalAction ... re_unit.5D

They say that I must write:

Code: Select all

[store_unit]
[filter]
 id = Unit_ID
[/filter]
# variable
[/store_unit]
Then goes "variable: the name of the variable into which to store the unit(s)".
What exactly I must assign to this variable?
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: WML [move_unit] to other unit's current position

Post by Pentarctagon »

Wesnoth will store the unit's information, including its x and y coordinates, into that variable.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
Post Reply