Code: Select all
<!-- # 1 --><waypoint x="31630" z="2716"> __WPL:reverse(); </waypoint>
...
<!-- #350 --><waypoint x="27923" z="6789"> __WPL:reverse(); </waypoint>
Code: Select all
<!-- # 1 --><waypoint x="31630" z="2716"> __WPL:reverse(); </waypoint>
...
<!-- #350 --><waypoint x="27923" z="6789"> __WPL:reverse(); </waypoint>
Code: Select all
if( __WPL.Direction == WPT_BACKWARD ) then
__WPL:reverse(); -- Start going forward again.
end
Using __WPL:setDirection(WPT_BACKWARD); gives the same (no)result:/Administrator wrote: There's another function, __WPL:setDirection(dir) (accepts WPT_FORWARD or WPT_BACKWARD), but this might need to be fixed as well (basically, to just do the above code).
Code: Select all
Const ForReading = 1
Const ForWriting = 2
Dim arrLines()
i = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\micromacro\scripts\rom\waypoints\pełnaścierzkadopliku.xml", ForReading)
Do Until objFile.AtEndOfStream
Redim Preserve arrLines(i)
arrLines(i) = objFile.ReadLine
i = i + 1
Loop
objFile.Close
Set objFile = objFSO.OpenTextFile("c:\micromacro\scripts\rom\waypoints\pełnaścierzkadopliku_reversed.xml", ForWriting)
For i = Ubound(arrLines) to LBound(arrLines) Step -1
objFile.WriteLine arrLines(i)
Next
objFile.Close
Code: Select all
<!-- # 1 --><waypoint x="123" z="123">__WPL:reverse();__WPL:setWaypointIndex(2); </waypoint>
...
<!-- # 69 --><waypoint x="456" z="456">__WPL:reverse();__WPL:setWaypointIndex(68); </waypoint>
Good I see? __WPL:reverse(); have to be called 2 times (#69 call __WPL:reverse(); > then go to 68 (next will be 69) > __WPL:reverse(); ?)jurafxp wrote:i am using this:
Code: Select all
<!-- # 1 --><waypoint x="123" z="123">__WPL:reverse();__WPL:setWaypointIndex(2); </waypoint> ... <!-- # 69 --><waypoint x="456" z="456">__WPL:reverse();__WPL:setWaypointIndex(68); </waypoint>
Code: Select all
-- Reverse your current direction
function CWaypointList:reverse()
if( self.Direction == WPT_FORWARD ) then
self.Direction = WPT_BACKWARD;
self.CurrentWaypoint = self.CurrentWaypoint - 1;
if( self.CurrentWaypoint <= 0 ) then
self.CurrentWaypoint = #self.Waypoints - 1;
end
else
self.Direction = WPT_FORWARD;
end;
end
Code: Select all
-- Reverse your current direction
function CWaypointList:reverse()
if( self.Direction == WPT_FORWARD ) then
self.Direction = WPT_BACKWARD;
self.CurrentWaypoint = self.CurrentWaypoint - 1;
if( self.CurrentWaypoint <= 0 ) then
self.CurrentWaypoint = #self.Waypoints - 1;
end
else
self.Direction = WPT_FORWARD;
self.CurrentWaypoint = self.CurrentWaypoint + 1;
if( self.CurrentWaypoint >= #self.Waypoints ) then
self.CurrentWaypoint = 2;
end
end;
end
Code: Select all
function CWaypointList:setDirection(wpt)
if( wpt ~= WPT_FORWARD and wpt ~= WPT_BACKWARD ) then
return; -- do nothing, invalid input
end
if( wpt ~= self.Direction ) then
self:reverse();
end
end
I can confirm that setdirection wasn't working.Administrator wrote:Is someone able to help me test this?
Code: Select all
-- Sets the "direction" (forward/backward) to travel
function CWaypointList:setDirection(wpt)
-- Ignore invalid types
if( wpt ~= WPT_FORWARD and wpt ~= WPT_BACKWARD ) then
return;
end;
if( wpt ~= self.Direction ) then
self.Direction = wpt
if( wpt == WPT_BACKWARD ) then
self.CurrentWaypoint = self.CurrentWaypoint - 1;
if( self.CurrentWaypoint <= 0 ) then
self.CurrentWaypoint = #self.Waypoints - 1;
end
else
self.CurrentWaypoint = self.CurrentWaypoint + 1;
if( self.CurrentWaypoint >= #self.Waypoints ) then
self.CurrentWaypoint = 2;
end
end;
end
end
-- Reverse your current direction
function CWaypointList:reverse()
if( self.Direction == WPT_FORWARD ) then
self:setDirection(WPT_BACKWARD);
else
self:setDirection(WPT_FORWARD);
end;
end
Confirmed - Worksrock5 wrote:I noticed you still haven't committed these changes. In the mean time I've been thinking. We have them back-to-front.
setdirection uses reverse but I think it should be reverse that uses setdirection. Makes more sense to me. So I changed them around and tested them, the code is below. They both work correctly. If you agree with me, feel free to add to next commit. Otherwise use the fixes above.
Users browsing this forum: Ahrefs [Bot] and 3 guests