Need help with sticky teleport code.
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.
Need help with sticky teleport code.
Code: Select all
#define LANDINGHEX NUMBER X Y
[if]
[variable]
name=random
numerical_equals={NUMBER}
[/variable]
[then]
x={X}
y={Y}
[/then]
[/if]
#enddef
#Co-ords for middles:
# 3,4 9,4 15,4
# 6,8 12,8 18,8
# 3,13 9,13 15,13
# 6,17 12,17 18,17
#define TELEPORTINGMIDDLE X Y
[event]
name=moveto
first_time_only=no
[filter]
x={X}
y={Y}
[/filter]
{RANDOM 1..12}
[teleport]
[filter]
x={X}
y={Y}
[/filter]
LANDINGHEX 1 3 4
LANDINGHEX 2 9 4
LANDINGHEX 3 15 4
LANDINGHEX 4 6 8
LANDINGHEX 5 12 8
LANDINGHEX 6 18 8
LANDINGHEX 7 3 13
LANDINGHEX 8 9 13
LANDINGHEX 9 15 13
LANDINGHEX 10 6 17
LANDINGHEX 11 12 17
LANDINGHEX 12 18 17
[/teleport]
[/event]
#enddef
TELEPORTINGMIDDLE 3 4
TELEPORTINGMIDDLE 9 4
TELEPORTINGMIDDLE 15 4
TELEPORTINGMIDDLE 6 8
TELEPORTINGMIDDLE 12 8
TELEPORTINGMIDDLE 18 8
TELEPORTINGMIDDLE 3 13
TELEPORTINGMIDDLE 9 13
TELEPORTINGMIDDLE 15 13
TELEPORTINGMIDDLE 10 6 17
TELEPORTINGMIDDLE 11 12 17
TELEPORTINGMIDDLE 12 18 17
As far as I see, the first code block should give out an X and a Y based on the random variable RANDOM.
The second code block initiates teleport of whoever is on the coordinates specified, randomizes RANDOM, calls in the first code block to give it a X and a Y, then teleports the unit there.
But it doesn't work.
-
- Posts: 873
- Joined: July 4th, 2004, 9:14 pm
- Location: My imagination
- Contact:
Re: Need help with sticky teleport code.
You need braces, but the problem is, you can't put [if] inside [teleport] or x= and y= inside [then]. The x= and y= must be directly inside [teleport], and the ones inside [then] make no difference. In fact, putting an [if] inside [teleport] has no effect, because that is not a place where Wesnoth expects a command (or the new use: inside a [story] tag). Wesnoth's cfg engine will totally ignore tags and attributes that don't belong where you put them. Here's the fixed code:
Code: Select all
#define LANDINGHEX NUMBER X1 Y1 X2 Y2
[if]
[variable]
name=random
numerical_equals={NUMBER}
[/variable]
[then]
[teleport]
[filter]
x={X1}
y={Y1}
[/filter]
x={X2}
y={Y2}
[/teleport]
[/then]
[/if]
#enddef
#Co-ords for middles:
# 3,4 9,4 15,4
# 6,8 12,8 18,8
# 3,13 9,13 15,13
# 6,17 12,17 18,17
#define TELEPORTINGMIDDLE X Y
[event]
name=moveto
first_time_only=no
[filter]
x={X}
y={Y}
[/filter]
{RANDOM 1..12}
{LANDINGHEX 1 {X} {Y} 3 4}
{LANDINGHEX 2 {X} {Y} 9 4}
{LANDINGHEX 3 {X} {Y} 15 4}
{LANDINGHEX 4 {X} {Y} 6 8}
{LANDINGHEX 5 {X} {Y} 12 8}
{LANDINGHEX 6 {X} {Y} 18 8}
{LANDINGHEX 7 {X} {Y} 3 13}
{LANDINGHEX 8 {X} {Y} 9 13}
{LANDINGHEX 9 {X} {Y} 15 13}
{LANDINGHEX 10 {X} {Y} 6 17}
{LANDINGHEX 11 {X} {Y} 12 17}
{LANDINGHEX 12 {X} {Y} 18 17}
[/event]
#enddef
{TELEPORTINGMIDDLE 3 4}
{TELEPORTINGMIDDLE 9 4}
{TELEPORTINGMIDDLE 15 4}
{TELEPORTINGMIDDLE 6 8}
{TELEPORTINGMIDDLE 12 8}
{TELEPORTINGMIDDLE 18 8}
{TELEPORTINGMIDDLE 3 13}
{TELEPORTINGMIDDLE 9 13}
{TELEPORTINGMIDDLE 15 13}
{TELEPORTINGMIDDLE 10 6 17}
{TELEPORTINGMIDDLE 11 12 17}
{TELEPORTINGMIDDLE 12 18 17}
Play a Silver Mage in the Wesvoid campaign.