Waypoint Renumbering

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
Binafus
Posts: 23
Joined: Thu Jul 09, 2009 1:22 pm

Waypoint Renumbering

#1 Post by Binafus » Thu Jul 22, 2010 7:48 pm

ROM server is down so I wrote a simple autoit script to renumber waypiont files.

I know when I'm making a waypoint path I always end up changing the path by adding and deleting waypionts.

The waypiont numbers are then not numbered right which makes it harder to edit existing paths.

Not sure if you guys want stuff like this posted or not.

Code: Select all

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.6.1
 Author:         Binafus

 Script Function:
	Renumbering Waypoint Files

#ce ----------------------------------------------------------------------------

; Opens up a File Selection Box
$var = FileOpenDialog("Choose a file", "",  "(*.xml;*.XML)", 1 + 4 )

If @error Then
    MsgBox(4096,"","No File(s) chosen")
Else
    $var = StringReplace($var, "|", @CRLF)
;    MsgBox(4096,"","Your New Waypoint File" & $var)   ; for testing input file
EndIf

$filein = FileOpen($var, 0)
$fileout = FileOpen((StringTrimRight($var,4) & " New.xml"), 2)

; if you wish to not have a Windows File Selection Box delete lines above this line and uncoment the two below
;$filein = FileOpen("name_of_waypoint_file.xml", 0)  ; Manually put in your file name 
;$fileout = FileOpen("Name of Output File .xml", 2)


; Check if file opened for writing OK
If $fileout = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Check if file opened for reading OK
If $filein = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf


; reads lines from the input file searches for the keyword "<waypoint" then replaces with new waypoint numbers0
$query="<waypoint "
$x = 0;
While 1
	$line = FileReadLine($filein)
	If @error = -1 Then ExitLoop
	$line_result = StringInStr($line, "<waypoint")

	If $line <> "" Then
		If StringInStr($line,$query) Then
			$x = $x +1;
			If $x < 10 Then
				FileWriteLine($fileout, "<!-- #  " & $x & " -->" & @TAB & StringTrimLeft($line,($line_result-1)))		
			ElseIf  $x < 100 Then
				FileWriteLine($fileout, "<!-- # " & $x & " -->" & @TAB & StringTrimLeft($line,($line_result-1)))
			Else
				FileWriteLine($fileout, "<!-- #" & $x & " -->" & @TAB & StringTrimLeft($line,($line_result-1)))		
			EndIf
		else 
			FileWriteLine($fileout, $line)
		EndIf
	EndIf
Wend

FileClose($filein)
FileClose($fileout)
Attachments
Waypoint Renumber.rar
compiled version
(278.97 KiB) Downloaded 140 times

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 17 guests