Page 1 of 1

Is WPL:reverse broken?

Posted: Sat Oct 02, 2010 8:01 pm
by Giram
Hi

I was making waypoint file that goes from a to b and would go back using same line. At the end of the line there is npc and i do check just before that if i would go back or repair.

Code: Select all

<!-- # 57 --><waypoint x="1701" z="-3952">    </waypoint>
    <!-- # 58 --><waypoint x="1608" z="-4094">
    local dura = inventory:getMainHandDurability();
    printf("Durability:%s\n", dura);
    if( dura < 90 ) then
        __WPL:setWaypointIndex(__WPL:findWaypointTag("gorepair"));    
    else
        __WPL:reverse();
    end
    
    </waypoint>
    <!-- #  59 --><waypoint x="1666" z="-4163" tag="gorepair">    </waypoint>
    <!-- #  60 --><waypoint x="1683" z="-4639">    </waypoint>
    <!-- #  61 --><waypoint x="1712" z="-4695">
        player:merchant("Isaac Kaid");
        __WPL:reverse();
    </waypoint>
It goes repair but after that it gets stuck on loop. Do i do something wrong here? I am using nevest rev 503.

Re: Is WPL:reverse broken?

Posted: Sat Oct 02, 2010 8:35 pm
by rock5
Your logic is wrong. When it is coming back from repair, the direction is set to backwards. When it gets to point 58 dura is > 90 so it executes the Reverse() command that changes the direction to forward again. So it heads to repair again.

Here's a tip: You hardly ever want to use reverse. Reverse() makes a choice; if you are going forward then go backward, if you are going backward go forward. But usually where it is used it only is expected to change to 1 direction eg. at the end of a file you expect it to only change the direction to backwards.

So, instead try using,

Code: Select all

__WPL:setDirection(WPT_BACKWARD)
when you want to go backwards and

Code: Select all

__WPL:setDirection(WPT_FORWARD)
when you want to go forward.

I, personally, can't think of a situation where I would ever use reverse().

Re: Is WPL:reverse broken?

Posted: Sun Oct 03, 2010 3:35 am
by Giram
Thanks.

That fixed this problem. I thought that reverse() does same thing than __WPL:setDirection(WPT_BACKWARD) did.

This is from wiki:

Code: Select all

__WPL:reverse();
"Resort the waypoints. Means after running from 1 to 20 you can now run from 20 - 1. It is usefull to put that at the first and at the last waypoint if you want to run between two places."