Hi All,
I came back to TW a few weeks ago after 10+ years gone. Been having fun so far, and am really liking TWX Proxy.
I'm a Programmer (MS SQL), so I like writing my own scripts to accomplish exactly what I want without any unnecessary fluff. There are a lot of good public scripts out there, but most do not seem to be as efficient as they could be.
A problem I have been having for a while has been finding a way to track my Fig Grids in a dynamic way that can be accessible to all Scripts that I run.
I started out loading my FigList at the start of every script I run. In a 20K Sector Game, this is inefficient as hell, and makes testing the scripts a nightmare when you have to wait for the Figlist to load just to see if one part of unrelated code that was changed had the desired effect.
Also, this method was great for adding Figs to the FigList Array for use within the main Script, but keeping track of Figs that are destroyed while the main Script is running is a logistical nightmare.
I thought I found a solution when I set up a System Script to do: setArray $FigList SECTORS
Then I could just track my Figlist Array in a seperate System Script. Unfortunately (I did not know this at the time), it appears the Variables set by one script are not visible to other scripts that are running, even though all active Variables are visible from the "Menu> Script> V" command, regardless of which script created them. Go figure.
I've spent the last couple days searching around for a solution. I've found a dozen or more posts asking for a way to do it, but none that actually had a solution. I finally found a solution a couple hours ago and wanted to share it in case anyone else was still looking for something similar.
If this solution has been found before, great, but I could not locate it anywhere.

The answer lies in the setSectorParameter and getSectorParameter commands:
The code example below is what I came up with:
(Comments where I thought they might be needed)
### ============================================================ ==========
# Dark Jester's Fig Tracker
# Set this as a System Script so we don't accidentally Terminate it
systemScript
:FigTrackerStartup
# Wipe out any info from previous times this Script has run.
# This only takes 3-7 seconds for a 20K Universe on my machine
setVar $i 1
while ($i <= SECTORS)
setSectorParameter $i "Figged" "0"
add $i 1
end
:FigFileRefresh
# We need fresh Fig Information
echo "** " ANSI_10 "Refreshing Fig Info - Please Wait ...*"
send "G"
waitOn "==========================="
:CycleRefresh
# Same as most other scripts that get Fig Info for a FigList Array or Fig File
if (CURRENTLINE = "=========================================================== ")
goto :CycleRefreshNext
else
getWord CURRENTLINE $FigSector 1
getWord CURRENTLINE $FigListFinished 2
end
if ($FigListFinished = "Total")
goto :FinishFigRefresh
end
# This is the difference. Instead of using an Array like "setVar $FigList[$Sector] 1"
# setSectorParameter sets a 'Variable' for the specified Sector within the TWX Database itself.
# This Variable is visible to all Scripts via the getSectorParameter command.
setSectorParameter $FigSector "Figged" "1"
:CycleRefreshNext
# Get the next Fig for the Refresh
setTextLineTrigger GetFigInfo :CycleRefresh
pause
:FinishFigRefresh
# Done loading the Fig Info into the Database
echo "** " ANSI_10 "Fig Info Refreshed - Fig Tracker Running ...*"
:FigTrackerWait
# This is the Idle Script that watches for Figs that are Destroyed.
# I could probably do a further check to make sure the Player actually attacked
# before erasing the Fig from the Database, but 99.99% of the time, when a player enters
# a Sector with a Fig in it, they kill it.
setTextLineTrigger PlayerFigHit

layerFigHit "Deployed Fighters Report Sector"
pause

layerFigHit
# A Player entered the Sector
killTrigger PlayerFigHit
getWord CURRENTLINE $FigHitCheck 1
getWord CURRENTLINE $SectorHit 5
stripText $SectorHit ":"
if ($FigHitCheck = "Deployed")
# Make sure it was a Player. This sets the Sector to 'No Fig' for Script purposes.
setSectorParameter $SectorHit "Figged" "0"
end
goto :FigTrackerWait
### ============================================================ ==========
And that's it. The Script only needs to be run once when you log in, and it will update itself after that by removing any Figs that are destroyed (by Players). Any Script you run can access this information since it is stored as Static Info in the Database, not as a temporary (Invisible) Variable.
Adding Figs to this 'Array' can be done in the individual scripts that you run. Any time your other Scripts place a Fig, have them also send the Command: setSectorParameter $FigSector "Figged" "1"
Other Triggers can be set in the Idle Section to track Ferrengi Fig Hits, or Extern's MSL Fig Hits.
To pull the data back out of the Database, say in a Breadth Search for Near Fig:
(Breadth Structure borrowed from Elder Prophet)
### ============================================================ ==========
:NearFigSearch
setVar $Start $CurrentSector
setVar $MaxDistance 15
setVar $Top 1
setVar $Queue[$Top] $Start
setArray $Checked SECTORS
setVar $Checked[$Start] 1
setVar $Bottom 1
while ($Bottom <= $Top)
setVar $Focus $Queue[$Bottom]
getDistance $DistanceTo $Start $Focus
if ($DistanceTo > $MaxDistance)
goto :NoFigFound
end
setVar $k 1
while ($k <= SECTOR.WARPCOUNT[$Focus])
setVar $Adjacent SECTOR.WARPS[$Focus][$k]
if ($Checked[$Adjacent] = 0)
getSectorParameter $Adjacent "Figged" $FigCheck
if ($FigCheck = 1)
setVar $FigSector $Adjacent
goto :FigFound
end
add $Top 1
setVar $Queue[$Top] SECTOR.WARPS[$Focus][$k]
setVar $Checked[$Adjacent] 1
end
add $k 1
end
add $Bottom 1
end
:NoFigFound
echo "No Fig Within 15 Hops."
return
:FigFound
echo "Fig Found in Sector: " & $FigSector
return
### ============================================================ ==========
I hope this helps anyone that was not aware of it.

If there are any questions or comments, give a shout.
Thanks,
-Dark Jester