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

PlanetDisplay.ts
https://mail.black-squirrel.com/viewtopic.php?f=15&t=25339
Page 1 of 2

Author:  Promethius [ Tue Dec 29, 2009 6:20 pm ]
Post subject:  PlanetDisplay.ts

The script below will do a TL command and then redisplay (echo to screen) all planets in sector order instead of creation order. This allows viewing a base by sector and the planets within the sector together. The echo output is displayed below. The code does show a bubble sort routine that some may find useful.

My thanks to those that gave up their planets for this display.

Attachment:
planetdisp.PNG
planetdisp.PNG [ 38.12 KiB | Viewed 9618 times ]



Code:
# planetDisplay.ts by Promethius
# planet displays sorted by sector order
# display lines used to seperate bases
# echos to screen display only


send "v"
setTextLineTrigger maxPlanets :maxPlanets "The Maximum number of Planets per sector:"
pause
:maxPlanets
getword currentLine $maxPlanets 8
stripText $maxPlanets ","
send "|tl"
waitfor "=============================================================================="
setVar $i 1
setVar $toggle 0
:trg
setTextLineTrigger getLine :lineOut ""
setTextTrigger done :sortSectors "Corporate command"
pause

:lineOut
getword currentline $chkDone 1
if ($chkDone = "======")
     goto :skip
end
getwordpos currentline $sectorLine "Class"
if ($sectorLine > 0)
    setVar $sector[$i] $chkDone
end

add $toggle 1
if ($toggle = 1)
      setVar $line[$i] currentANSILine
elseif ($toggle = 2)
    setVar $line2[$i] currentANSILine
    setVar $toggle 0
    add $i 1
end
:skip
setTextLineTrigger getLine :lineOut ""
pause


:sortSectors
  setVar $ii ($i - 1)
  while ($ii >= 1)
    setVar $ij 1
    while ($ij <= ($ii - 1))
      setVar $ijDist1 $sector[$ij]
      stripText $ijDist1 ","
      setVar $ijNext ($ij + 1)
      setVar $ijDist2 $sector[$ijNext]
      stripText $ijDist2 ","
      if ($ijDist1 < $ijdist2)
        setVar $temp $sector[$ij]
        setVar $tempLine $line[$ij]
        setVar $tempLine2 $line2[$ij]
        setVar $Sector[$ij] $Sector[$ijNext]
        setVar $line[$ij] $line[$ijNext]
        setVar $line2[$ij] $line2[$ijNext]
        setVar $Sector[$ijNext] $temp
        setVar $line[$ijNext] $tempLine
        setVar $line2[$ijNext] $tempLine2
       end
      add $ij 1
    end
    subtract $ii 1
  end

:display
killtrigger getline
send "q"
echo ansi_15 "**                           Corporate Planet Scan"
echo "*"
echo ansi_11 "* Sector  Planet Name    Ore  Org  Equ   Ore   Org   Equ   Fighters    Citadel"
echo ansi_11 "* Shields Population    -=Productions=-  -=-=-=-=-On Hands-=-=-=-=-    Credits"
echo ansi_13 "*==============================================================================*"
setVar $dispCnt 1
setVar $sectorChng $sector[1]
setVar $overLoadCnt 0
while ($dispCnt < $i)
   if ($sectorChng <> $sector[$dispCnt])
         echo ansi_9 "------------------------------------------------------------------------------*"
      getword SECTOR.UPDATED[$sectorChng] $moDay 1
      getLength $moDay $len
      cutText $moDay $moDay 1  ($len - 5)
      getword SECTOR.UPDATED[$sectorChng] $hhmm 2
      getword SECTOR.UPDATED[$sectorChng] $amPM 3
      getDistance $dist currentSector $sectorChng
      if ($dist < 1) and (currentSector <> $sectorChng)
         setVar $dist "Unknown"
      elseif (currentSector = $sectorChng)
         setVar $dist "0"
      end
      echo ANSI_6 "  Dist: " $dist
      echo ansi_6 "  Figs: " SECTOR.FIGS.QUANTITY[$sectorChng]
      echo "  Armd: " SECTOR.MINES.QUANTITY[$sectorChng]
      echo "  Lmpt: " SECTOR.LIMPETS.QUANTITY[$sectorChng]
      echo "  Last: " $moDay " " $hhmm " " $amPM "*"
      if ($overLoadCnt > $maxPlanets)
         echo #27 "[1;5;31m           !!!! Overloaded Sector !!!!*" #27 "[0;1;34;40m"
      end
      echo ansi_9 "------------------------------------------------------------------------------*"
      setVar $sectorChng $sector[$dispCnt]
      setVar $overLoadCnt 1
   else
      add $overLoadCnt 1
   end
   if (($dispCnt + 1) = $i)
       echo ansi_13 "======   ============  ==== ==== ==== ===== ===== ===== ========== ==========*"
   end
   echo $line[$dispCnt]
   echo $line2[$dispCnt]
   add $dispCnt 1
end
send "|"
halt

Author:  Thrawn [ Tue Dec 29, 2009 6:30 pm ]
Post subject:  Re: PlanetDisplay.ts

Very slick Promethius. Was it a hard-won victory to get the planets for your display? Lol

Cheers

Author:  Parrothead [ Tue Dec 29, 2009 6:33 pm ]
Post subject:  Re: PlanetDisplay.ts

Useful piece of display code..thanx!

but you could have caught the whole line with Currentansiline and saved all the origanal ansi color codes as well

Author:  Promethius [ Tue Dec 29, 2009 7:31 pm ]
Post subject:  Re: PlanetDisplay.ts

I have updated the code to display the correct colors as seen in the TL display. I am not sure why I didn't think of currentAnsiLine the first time and use its capture to echo back.

Author:  Parrothead [ Tue Dec 29, 2009 8:26 pm ]
Post subject:  Re: PlanetDisplay.ts

good stuff....i popped it in my bot on a hotkeyy

Author:  T0yman [ Tue Dec 29, 2009 8:44 pm ]
Post subject:  Re: PlanetDisplay.ts

Looks great but for I have one missing.

Here is what the script shows:
Attachment:
pic.JPG
pic.JPG [ 110.83 KiB | Viewed 9619 times ]


Here is a sector scan:
Attachment:
pic2.JPG
pic2.JPG [ 36.15 KiB | Viewed 9619 times ]

Seems planet 5 is being skipped tried it several times, just thought I would pass the info along.

Author:  Promethius [ Tue Dec 29, 2009 9:16 pm ]
Post subject:  Re: PlanetDisplay.ts

I think I found the issue at the very top of the script. $i was set to 0 and should have been set to 1. I have corrected the code that is posted in the first message. See if that works and let me know please.

Author:  T0yman [ Tue Dec 29, 2009 9:31 pm ]
Post subject:  Re: PlanetDisplay.ts

Yea Prom, that seems to have resolved the issue, thanks again for some good coding.

Attachment:
pic3.JPG
pic3.JPG [ 49.25 KiB | Viewed 9618 times ]

Author:  Promethius [ Wed Dec 30, 2009 2:32 am ]
Post subject:  Re: PlanetDisplay.ts

One thing that people might want to do in the script is turn off messages at the start of the script and then turn them back on at the end. Since the script is using a setTextLineTrigger that triggers off of "", fighter hits or a message could mess the display up a bit. Toggle messages with: send "|"

Author:  Parrothead [ Wed Dec 30, 2009 2:38 am ]
Post subject:  Re: PlanetDisplay.ts

I use this include.


Code:
#Parrothead Comms Controler Include
#=-=-=-=-=-=--=
:off
killalltriggers
setdelaytrigger 3off :offcomms 3000
setTexttrigger 1off :1off "Displaying all messages"
setTexttrigger 2off :2off "Silencing all messages"
send "|"
pause
:offcomms
killtrigger 3off
killTrigger 1off
killTrigger 2off
goto :off
:1off
killtrigger 3off
killTrigger 1off
killTrigger 2off
send "|"
:2off
killtrigger 3off
killTrigger 1off
killTrigger 2off
echo ANSI_3 "<<<" & ANSI_12 "Comm's Off" & ANSI_3 ">>>" ANSI_0
return
#=-=-=-=-=-=--=
:on
killalltriggers
setdelaytrigger 2on :oncomms 3000
setTexttrigger 3on :3on "Displaying all messages"
setTexttrigger 4on :4on "Silencing all messages"
send "|"
pause
:oncomms
killtrigger 2on
killTrigger 3on
killTrigger 4on
goto :on
:4on
killtrigger 2on
killTrigger 3on
killTrigger 4on
send "|"
:3on
killtrigger 2on
killTrigger 3on
killTrigger 4on
echo ANSI_3 "<<<" & ANSI_15 "Comm's On" & ANSI_3 ">>>" ANSI_0
return

Author:  Promethius [ Wed Dec 30, 2009 6:52 pm ]
Post subject:  Re: PlanetDisplay.ts

Thanks PH on the addition that people can use. That along with the changes that were made since the initial post show how scripts change. The snippet below is a replacement for part of the code to display sector fighters/armids/limpet and give the time the sector was last viewed. If anyone want this, just search for the if statement, copy the below, and then paste over the original (if to end).

... and I didn't do a very good job of cropping the picture.. the top line went with the previous sector.

Attachment:
planetdispsm.png
planetdispsm.png [ 20.45 KiB | Viewed 9527 times ]


Code:
   if ($sectorChng <> $sector[$dispCnt])
         echo ansi_9 "------------------------------------------------------------------------------*"
      getword SECTOR.UPDATED[$sectorChng] $moDay 1
      getLength $moDay $len
      cutText $moDay $moDay 1  ($len - 5)
      getword SECTOR.UPDATED[$sectorChng] $hhmm 2
      getword SECTOR.UPDATED[$sectorChng] $amPM 3
      echo ansi_6 "  Sector Figs:  " SECTOR.FIGS.QUANTITY[$sectorChng]
      echo "  Armd: " SECTOR.MINES.QUANTITY[$sectorChng]
      echo "  Lmpt: " SECTOR.LIMPETS.QUANTITY[$sectorChng]
      echo "  Last: " $moDay " " $hhmm " " $amPM "*"
      echo ansi_9 "------------------------------------------------------------------------------*"
      setVar $sectorChng $sector[$dispCnt]
   end

Author:  Parrothead [ Thu Dec 31, 2009 12:24 am ]
Post subject:  Re: PlanetDisplay.ts

Why does the DATE Show but "0" "0" for time if I have never visited?

Author:  Promethius [ Thu Dec 31, 2009 12:56 am ]
Post subject:  Re: PlanetDisplay.ts

Parrothead wrote:
Why does the DATE Show but "0" "0" for time if I have never visited?


That is a good question and one I can't answer except for a guess. I am pulling the last visit from TWX's database, so as a guess, the field gets populated when the database is created with the date - I really don't know. I am just happy that it didn't crash because I hadn't tested against that.

I probably should test to see if $hhmm is a number and if so then set a var to display "Never Visited" or something to that effect.

Author:  Parrothead [ Thu Dec 31, 2009 2:49 am ]
Post subject:  Re: PlanetDisplay.ts

Getting some raw ansi code in some games echoing ":35]"


It showed todays date but no time in other issue

Author:  Parrothead [ Fri Jan 08, 2010 12:15 am ]
Post subject:  Re: PlanetDisplay.ts

I add distance from current sector to my copy

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