[object] trouble

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
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

[object] trouble

Post by zookeeper »

What is wrong with this?

Code: Select all

[multiplayer]
    id=Test
    name= _ "Test"
    map_data="gggggggggggggggggggggggggggggggggggggg
gggggggggggggggggggggggggggggggggggggg
gggggggggggggggggggggggggggggggggggggg
gggggggggggggggggggggggggggggggggggggg
gggggggggggggggggggggggggggggggggggggg
ggggggggggCCCggggggggggggggggggggggggg
ggggggggggC1Cggggggggggggggggggggggggg
ggggggggggCCCggggggggCCCgggggggggggggg
gggggggggggggggggggggC2Cgggggggggggggg
gggggggggggggggggggggCCCgggggggggggggg
gggggggggggggggggggggggggggggggggggggg
gggggggggggggggggggggggggggggggggggggg
gggggggggggggggggggggggggggggggggggggg
gggggggggggggggggggggggggggggggggggggg
gggggggggggggggggggggggggggggggggggggg"
    turns=20
    description= _ ""

    {DAWN}
    {MORNING}
    {AFTERNOON}
    {DUSK}
    {FIRST_WATCH}
    {SECOND_WATCH}

    [side]
        side=1
        canrecruit=1
        enemy=2
        controller=human
    [/side]

    [side]
        side=2
        canrecruit=1
        enemy=1
        controller=human
    [/side]

    [event]
        name=side turn
        first_time_only=no

        [store_unit]
            [filter]
                side=$side_number
            [/filter]

            variable=stored_units
            kill=no
            animate=no
        [/store_unit]

        {FOREACH stored_units i}
            [object]
                duration=forever
                silent=yes

                [filter]
                    x=$stored_units[$i].x
                    y=$stored_units[$i].y
                [/filter]

                [effect]
                    apply_to=new_attack
                    name="foo"
                    damage=10
                    number=10
                    type=impact
                    range=short
                [/effect]
            [/object]
        {NEXT i}
    [/event]
[/multiplayer]
Obviously, when player 1 starts his turn (excluding the first turn), every one of his units should gain that new attack. Same for side 2. The problem is that, for each side, all the objects are given to one unit. To be more precise, stored_units[0].

The wiki does state that [objects] might behave oddly outside of moveto events, but this doesn't really make sense and I'd think that something like this would be outdated information. Any ideas on where the bug is and how to go around it in this case?
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

Code: Select all

$stored_units[$i].x
Try renaming this as another variable with a variable format statement immediately before the object tag. The dollar signs aren't always expressed properly.

Code: Select all


        {FOREACH stored_units i} 

[set_variable]
name=temp_x
format=$stored_units[$i].x
[/set_variable]
[set_variable]
name=temp_y
format=$stored_units[$i].y
[/set_variable]

            [object] 
                duration=forever 
                silent=yes 

                [filter] 
                    x=$temp_x 
                    y=$temp_y
                [/filter] 

Hope springs eternal.
Wesnoth acronym guide.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Thank you, thank you! Excellent!
Post Reply