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

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

Author:  Kaus [ Thu Oct 09, 2008 1:25 am ]
Post subject:  Get Sectors

So I'm finally dusting off the old brain and trying something new (making a gridder), unfortunatly I'm allot worse off then I thought I was. The jumble of code below is my first attempt at getting sector numbers using a density scanner and then echoing the results. Unfortunatly I banging my head against the keyboard trying to see what im doing wrong. I feel like I'm missing something that I did with TerraFarmer but as I wrote that over a year ago I can't remember.

SetVar $SectorCount 0
#-----------------------Get Sectors-----------------------------#
:get_sec
KillAllTriggers
setTextLineTrigger get_sec :get_sec1 "Sector"
send "sd"
pause
:get_sec1
GetWord CURRENTLINE $Sector 2
If ($Sector = "(")
GetWord CURRENTLINE $Sector 3
end
StripText $Sector ")"
Add $SectorCount 1
GetWord $Warp[$SectorCount] $Sector 1
setTextLineTrigger get_sec2 :get_sec1 "Sector"
setTextLineTrigger done :done "Command [TL="
Pause
:done
Echo $Warp[$SectorCount]

Author:  Promethius [ Thu Oct 09, 2008 2:14 am ]
Post subject:  Re: Get Sectors

Kaus wrote:
So I'm finally dusting off the old brain and trying something new (making a gridder), unfortunatly I'm allot worse off then I thought I was. The jumble of code below is my first attempt at getting sector numbers using a density scanner and then echoing the results. Unfortunatly I banging my head against the keyboard trying to see what im doing wrong. I feel like I'm missing something that I did with TerraFarmer but as I wrote that over a year ago I can't remember.

SetVar $SectorCount 0
#-----------------------Get Sectors-----------------------------#
:get_sec
KillAllTriggers
setTextLineTrigger get_sec :get_sec1 "Sector"
send "sd"
pause
:get_sec1
GetWord CURRENTLINE $Sector 2
If ($Sector = "(")
GetWord CURRENTLINE $Sector 3
end
StripText $Sector ")"
Add $SectorCount 1
GetWord $Warp[$SectorCount] $Sector 1
setTextLineTrigger get_sec2 :get_sec1 "Sector"
setTextLineTrigger done :done "Command [TL="
Pause
:done
Echo $Warp[$SectorCount]


You will need to account for the following on sectors:

Sector ( 4164)
Sector ( 6066)
Sector 10407
Sector (18462)

If you just use a couple of stripText commands,, you can get rid of ( and ), and I would do that before using a getword. If I am just wanting to give a report when a density over a specified value is reached, I would use a getText currentline $highDensity "NavHaz : " "% Anom" followed by a striptext $highDensity " ". The trigger would be: SetTextLineTrigger denseTrigger :denseTrigger "Anom : "


Also something to think about is if you are scanning with the trigger: setTextLineTrigger get_sec :get_sec1 "Sector"
is: Deployed Fighters Report Sector

Author:  Singularity [ Thu Oct 09, 2008 2:19 am ]
Post subject:  Re: Get Sectors

You don't need to do any of that. If reqRecording is on your density scan will automatically update the database. Before you start just do a dz*, grab the sector number, and go from there. Then you can use the density in the database for the sectors adj to your current, no need to parse from the stream.

Author:  Kaus [ Thu Oct 09, 2008 9:11 am ]
Post subject:  Re: Get Sectors

Singularity wrote:
You don't need to do any of that. If reqRecording is on your density scan will automatically update the database. Before you start just do a dz*, grab the sector number, and go from there. Then you can use the density in the database for the sectors adj to your current, no need to parse from the stream.


So following your suggestions its more than likely going to be easier using.

SECTOR.DENSITY[inputted sector]

However, I'm confused as to how to go about getting the correct amount of warps out and then comparing there information to what I want the gridder to do? Being as that the script will continually scan then move, I'm curious if any sort of loop will create to many variables and how do i determine the difference between a sector with 2 warps out and a sector with 6. I assume the dz* is to update for sectors but it wont update adjacent density will it?

#------------Get Sectors-------------------
:get_sec
SetVar $Current CURRENTSECTOR
SetVar $SectorIndex 0
send "zd*"
SetVar $Sector1 SECTOR.WARPS[$current][1]
SetVar $Sector2 SECTOR.WARPS[$current][2]
SetVar $Sector3 SECTOR.WARPS[$current][3]
SetVar $Sector4 SECTOR.WARPS[$current][4]
SetVar $Sector5 SECTOR.WARPS[$current][5]
SetVar $Sector6 SECTOR.WARPS[$current][6]
:StartLoop
Add $SectorIndex 1
If ($Sector[$SectorIndex] = "0")
Return
Else
# compare variables for conditional movement
Goto :StartLoop
End
halt
#--------------------------------------------

Is there a easier way? Where it builds the variable as it goes? I'm using the variables for comparision to meet criteria for picking the warp untill which point it can't. Consider it a safe gridder in that it only grids empty space, at least thats my immediate goal, after which I will be adding conditions and the such.

Author:  Singularity [ Thu Oct 09, 2008 10:59 am ]
Post subject:  Re: Get Sectors

Quote:
However, I'm confused as to how to go about getting the correct amount of warps out and then comparing there information to what I want the gridder to do? Being as that the script will continually scan then move, I'm curious if any sort of loop will create to many variables and how do i determine the difference between a sector with 2 warps out and a sector with 6. I assume the dz* is to update for sectors but it wont update adjacent density will it?


If you do a dz* it'll update the sector display so you'll have the correct warps out. It will be slow tho, so if you hit a limpet in the landing sector you're going to get torped. Only way around that is to start w/ a partial map and build it up as you go.

If you want to also update the density you can do that w/ something like dz* sz* and just display and scan as you go. All of that text will slow you down, but it works in certain circumstances. With gridding it's all about circumstances.

How do you determine the warp count? With SECTOR.WARPCOUNT. It's all in the script manual.

Quote:
Is there a easier way? Where it builds the variable as it goes? I'm using the variables for comparision to meet criteria for picking the warp untill which point it can't. Consider it a safe gridder in that it only grids empty space, at least thats my immediate goal, after which I will be adding conditions and the such.


Passive gridder. I believe there's one in the twxproxy script pack, 1_scout or something like that. Be aware that gridding into unexplored sectors w/ 100 density can cause problems... ppl like me like to drop 20 figs in "no port" sectors (wrote it in as part of my passive gridder, laff) just to screw up ppl that don't scan. I've nabbed a lot of ppl that way.

Author:  ElderProphet [ Thu Oct 09, 2008 9:04 pm ]
Post subject:  Re: Get Sectors

A novice error when trying to use the database is expecting it to be updated before it is possible. Consider this routine that checks the first adjacent's density:
Code:
send "sd"
setVar $adjacent SECTOR.WARPS[CURRENTSECTOR][1]
echo "*Density in " $adjacent " = " SECTOR.DENSITY[$adjacent] "*"

Instead, you have to pause the code, ensuring that the query doesn't happen until after the density scan has been seen, E.g.:
Code:
send "sd"
waitOn "Relative Density Scan"
waitOn "Command [TL="
setVar $adjacent SECTOR.WARPS[CURRENTSECTOR][1]
echo "*Density in " $adjacent " = " SECTOR.DENSITY[$adjacent] "*"

Perhaps a basic example of querying the DB will be useful. A basic loop to scan over the adjacents, selecting the lowest density one to move to, might look something like this:
Code:
send "sd"
waitOn "Relative Density Scan"
waitOn "Command [TL="
setVar $lowestDensity 9999999
setVar $lowestDensitySector CURRENTSECTOR
setVar $i 1
while ($i <= SECTOR.WARPCOUNT[CURRENTSECTOR])
   setVar $adjacent SECTOR.WARPS[CURRENTSECTOR][$i]
   if (SECTOR.DENSITY[$adjacent] < $lowestDensity)
      setVar $lowestDensity SECTOR.DENSITY[$adjacent]
      setVar $lowestDensitySector $adjacent
   end
   add $i 1
end
send "m" $lowestDensitySector "*"

Good luck,
+EP+

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