;7/30/2004 V1.7
;********Basic setup (put at beginning of script)********************
gosub setup
;********Basic setup (put at beginning of script)********************

;*************Put your script in here********************************

;Put your scrit here
;working example
loop:
gosub loc
goto loop


;*************Put your script in here********************************

sub setup
key p alt
     menu Clear
     menu Window Title Rail Builder
     menu Window Color InactiveCaptionText
     menu Window Size 113 70
     menu Font Transparent #true
     menu Font Align Right
     menu Shape EUOShape1 0 2 17 70 1 7 1 Black 7 White
     menu Shape EUOShape2 96 2 17 70 1 7 1 Black 7 White
     menu Font Name MS Sans Serif
     menu Font Size 8
     menu Font Style
     menu Font Color WindowText
     menu Button EUOButton1 20 0 75 25 Continue
     menu Button EUOButton2 20 24 75 25 Start Script
     menu Button EUOButton3 20 48 75 25 Remove Last
     menu Show 421 270
set %autoback #true
set %nostop #false
set %cursor #false
set %first 0
set %n 0
set %o 0
gosub remember
set #MENUBUTTON EUOButton1
hh:
if #MENUBUTTON = EUOButton2
{
set #MENUBUTTON closed
menu hide
deletejournal
return
}
if #MENUBUTTON = EUOButton3
{
set #MENUBUTTON closed
set %nn %nn - 1
set %oo %oo - 1
goto hh
}
if #MENUBUTTON = EUOButton1
{
set #MENUBUTTON closed
set #TARGCURS 1
wait 20
waithere:
if #targcurs = 1
goto waithere
if %cursor = #false
{
set %set1 #LTARGETX
set %set2 #LTARGETY
set %set3 #LTARGETZ
}
ELSE
{
set %set1 #cursorx
set %set2 #cursory
}
gosub remember
}
goto hh
return

;===============End of Temp Rail Setup====================
;
;***************Sub Rail Area*******************************************
sub loc
MSG $
IF %nn => %FIRST + 1 && %autoback = #true
{
gosub gohome
return
}
if %nn < %first + 1
{
fullrail:
set %n %n + 1
set %o %o + 1
set %nn %nn + 1
set %oo %oo + 1
SET %MARK 0
set %x + 1
set %digspotx %digx . %n
set %digspoty %digy . %o
set %digspotz %digz . %n
set %movex %walk . %n
set %movey %wallk . %o
move %movex %movey 0 5s
if %movex <> #charposx && %movey <> #charposy
{
event pathfind %movex %movey
wait 1s
move %movex %movey 0 3s
}
if %nn < %first + 1 && %nostop = #true
goto fullrail
}
return


sub remember
set %first %first + 1
set %n %n + 1
set %o %o + 1
set %digx . %n %set1
set %digy . %o %set2
set %digz . %n %set3
set %walk . %n #charposx
set %wallk . %o #charposy
set %nn %n
set %oo %o
return

sub gohome
MSG $
SET %NNN %NN
moveagain:
set %nn %nn - 1
set %oo %oo - 1
move %walk . %nn %wallk . %oo 0 5s
if %walk . %nn <> #charposx && %wallk . %nn <> #charposy
{
event pathfind %walk . %nn %wallk . %nn
wait 1s
move %walk . %nn %wallk . %nn 0 3s
}
IF %NN => 1
goto moveagain
set %nn 1
set %oo 1
set %n 1
set %o 1
return

sub goback
MSG $
moveon:
IF %NNN => %FIRST + 1
{
RETURN
}
IF %NNN = %NN
RETURN
SET %N %N + 1
SET %O %O + 1
set %nn %nn + 1
set %oo %oo + 1
move %walk . %nn %wallk . %oo 0 5s
if %walk . %nn <> #charposx && %wallk . %nn <> #charposy
{
event pathfind %walk . %nn %wallk . %nn
wait 1s
move %walk . %nn %wallk . %nn 0 3s
}
goto moveon
return