Code: Select all
while $n.Counter.01 < $n.MaxSectors.X
|$n.Counter.02 = 0
|while $n.Counter.02 < $n.MaxSectors.Y
||$sec.Sector = get sector from universe index: x=$n.Counter.01, y=$n.Counter.02
||$a.Objects = find ship: sector=$sec.Sector class or type=Ship race=null flags=[Find.Multiple] refobj=null maxdist=null maxnum=200 refopos=null
||inc $n.Counter.02 =
|end
Wouldn't this overwrite $a.Objects so you only get the last sector in each column?
Some script I wrote for myself (to find abandoned ships in this case, but I copy and change it a lot, hence the generic names):
Code: Select all
001 $sectorX = 0
002 $sectorY = 0
003 $searchLimit = 25
004
005 skip if not $logfile
006 |write to log file #$logfile append=[FALSE] printf: fmt=' ', null, null, null, null, null
007
008 while $sectorY <= $searchLimit
009 |$sectorX = 0
010 |while $sectorX <= $searchLimit
011 ||
012 ||$currentSector = get sector from universe index: x=$sectorX, y=$sectorY
013 ||if $currentSector -> exists
014 |||
015 |||$objectArray = find ship: sector=$currentSector class or type=null race=null flags=[Find.Multiple] refobj=null maxdist=null maxnum=9999 refpos=null
016 |||
017 |||$numObjects = size of array $objectArray
018 |||while $numObjects > 0
019 ||||dec $numObjects =
020 ||||$currentObject = $objectArray[$numObjects]
021 ||||
022 ||||$pilot = $currentObject -> get pilot name
023 ||||if $pilot == 'No Pilot'
024 |||||$objectX = $currentObject -> get x position
025 |||||$objectY = $currentObject -> get y position
026 |||||$objectZ = $currentObject -> get z position
027 |||||
028 |||||$sectorName = sprintf: fmt='%s (%s,%s)', $currentSector, $sectorX, $sectorY, null, null
029 |||||$objectPos = sprintf: fmt='X%s, Y%s, Z%s', $objectX, $objectY, $objectZ, null, null
030 |||||
031 |||||write to player logbook: printf: fmt='%s; %s: %s.', $sectorName, $objectPos, $currentObject, null, null
032 |||||skip if not $logfile
033 ||||||write to log file #$logfile append=[TRUE] printf: fmt='%s; %s: %s', $sectorName, $objectPos, $currentObject, null, null
034 |||||
035 ||||end
036 |||end
037 ||end
038 ||
039 ||inc $sectorX =
040 |end
041 |
042 |inc $sectorY =
043 end
044
045 return null
fud wrote:Looks like a great way to tax your cpu.
It doesn't actually take very long to check every ship in the universe (as long as you're not doing it every second or whatever
).