www.ClassicTW.com
https://mail.black-squirrel.com/

Get a Distance
https://mail.black-squirrel.com/viewtopic.php?f=15&t=23335
Page 1 of 1

Author:  T0yman [ Fri Sep 18, 2009 7:52 am ]
Post subject:  Get a Distance

I am curious if there is a script that will get a all sectors from a set sector.

ie

SD if I wanted all sectors within 4 hops written to a file or displayed on screen.

The purpose is to use those sectors to have a sweeper script running to keep them clear from Nav Haz, Figs, Mines and Planets.

If there is already a script that does the distance could some one point me in that direction I would appreciate the assistance. I really don't want to recreate the wheel if it is already out there somewhere.

Author:  Singularity [ Fri Sep 18, 2009 8:20 am ]
Post subject:  Re: Get a Distance

getNearestWarps or getAllCourses

Very easily done (assuming you have a map).

Author:  T0yman [ Fri Sep 18, 2009 8:29 am ]
Post subject:  Re: Get a Distance

Yea I have the ZTM I am setting this up for a building type game, but I am new to writing scripts I will look at those thanks.

I am doing it by hand at the moment and then I can atleast have something to compare my results to.

Author:  Thrawn [ Fri Sep 18, 2009 9:43 am ]
Post subject:  Re: Get a Distance

T0yman wrote:
I am curious if there is a script that will get a all sectors from a set sector.

ie

SD if I wanted all sectors within 4 hops written to a file or displayed on screen.

The purpose is to use those sectors to have a sweeper script running to keep them clear from Nav Haz, Figs, Mines and Planets.

If there is already a script that does the distance could some one point me in that direction I would appreciate the assistance. I really don't want to recreate the wheel if it is already out there somewhere.


Did you take a look at the sweeper script that came with the OCSBot? I have it writing to a file and it does the sweep based on that file. You can use the script, dissect it for your needs if you want.

Author:  T0yman [ Fri Sep 18, 2009 11:43 am ]
Post subject:  Re: Get a Distance

Thanks Thrawn I will take a peek under the hood. I appreciate the help.

Author:  Thrawn [ Fri Sep 18, 2009 1:30 pm ]
Post subject:  Re: Get a Distance

T0yman wrote:
Thanks Thrawn I will take a peek under the hood. I appreciate the help.


No problem. Take a look in the OCSBot_sweep.ts script which gets the path from sector 1 to StarDock, then writes to the text file. Not too sure if that is what you were referring to. If it is, you can always use the sweep script in whatever you are doing. The code listed is the part that gets the path and writes to the file:

Code:

:getSD
send "v"
setTextLineTrigger sdSector :sdSector "The StarDock is located in sector"
pause
:sdSector
getword currentline $sd 7
stripText $sd "."
setVar $line ""
send "^f1*" $sd "*q"
waitfor "TO > " & $SD
:getPath
  setTextLineTrigger line :line ""
  pause
  :line
    getwordpos CURRENTLINE $pos ": ENDINTERROG"
    if ($pos > 0)
       goto :lineDone
    end
    setVar $line $line & CURRENTLINE
    setTextLineTrigger line :line ""
    pause
  :lineDone
   stripText $line ">"
   stripText $line "("
   stripText $line ")"
   echo "**" ANSI_12 $line
   delete $SentryFile
   getword $line $secNumber 2
   setVar $posCounter 2
   while ($secNumber <> 0)
          write $sentryFile $secNumber
          add $posCounter 1
          getword $line $secNumber $posCounter
    end
return


Author:  T0yman [ Fri Sep 18, 2009 1:44 pm ]
Post subject:  Re: Get a Distance

Yea I was looking at that a few minutes ago. What I am wanting is that I can setvar (anynumber) and it will give me a list of sectors within that area.

setTextLineTrigger dockSector :dockSector "The StarDock is located in sector "
send "v"
pause
:dockSector
setVar $dockLine CURRENTLINE
getWord $dockLine $dockSector 7
stripText $dockSector "."
getnearestwarps $center $docksector

that gets all warps but I am looking for a way to only extract a set number say I want 5 sectors around dock to be swept but you want 3 it could be a variable that reads in from either a text file or preset. I currently sweep 2 around dock and sector 1-10 removing all planets mines haz and figs >1 . Was just looking for an easier way to get the data for the sectors, not a huge deal Vids's script get the 2 out and I just use that file but it hangs on some of the other functions and it is compiled so I can't see the example of how he did it.
I did message him but he has been extremely busy so timing has not worked out on that. So I wrote my own sweeper form scratch but am missing the sector part.

Thanks for the help

Author:  ElderProphet [ Fri Sep 18, 2009 1:59 pm ]
Post subject:  Re: Get a Distance

You should try your hand at scripting. I've taken all of the hard work out of that kind of search with the getAllCourses command. If you look at the script reference that comes with TWX Proxy, script.html, you'll see an explanation and example which you could modify for your purposes. It would look something like this:
Code:
getAllCourses $courses STARDOCK
setVar $i 1
while ($i <= SECTORS)
   if ($i <> STARDOCK) and ($courses[$i] <= 4)
      echo "*" $i " is " $courses[$i] " hops."
   end
   add $i 1
end


And if you wanted to start with the sectors one hop from SD, you would change that evaluation to ($courses[$i] = 1). Then, if you wanted just those 2 hops out, run it = 2, and so on. No need to rerun the getAllCourses part, just the search part.

+EP+

Author:  T0yman [ Fri Sep 18, 2009 3:00 pm ]
Post subject:  Re: Get a Distance

Thanks to all! Who would have known if I read the documentation the answer was write there :shock:

I now have a good start on what I want. I will just add so it loops until it hit the magic sector distance from dock the write a file and I will be done. Much appreciated!

Author:  Thrawn [ Fri Sep 18, 2009 3:02 pm ]
Post subject:  Re: Get a Distance

<Nod> no problem. Glad to help.

Author:  Singularity [ Sat Sep 19, 2009 9:31 am ]
Post subject:  Re: Get a Distance

getAllCourses is usually the best way to go. But as getDistance is now really fast, if your looking at small hop numbers it might be slightly faster to run a getDistance check and abort based on it instead of using a getAllCourses array. That won't matter much if you just run the script once, but if it's part of a routine that's called a lot... it can make a big difference.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/