View unanswered posts | View active topics It is currently Wed Dec 31, 2025 6:09 pm



Reply to topic  [ 5 posts ] 
 Simple Holo Script 
Author Message
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post Simple Holo Script
The code below is a simple holoscan script that has some limitations, but also can be modified fairly easily to meet gridding requirements. It is based off of RammaR's code idea. The script will work "as is" with TWX 2.05, and should work with 2.04 with the end of line comments removed (the // comments).

Is it faster than using the normal triggers for a holoscan? Probably not, but it is different. Also there is a waitfor at the bottom of the code that will need to be removed - it is there so you can see how the variables report with the $sv command.

Code:
:begin
  send "sh"
  setVar $cs CURRENTSECTOR & " in"
  setTextLineTrigger sectorLine :sectorLine
  pause
  :sectorLine
   setVar $line currentline
   getwordpos $line $pos0 "Sector  : " & $cs        // setup current sector
   getWordPos $line $pos1 "Sector  :"               // so we don't get data from it
   getwordPos $line $pos2 "Ports   :"
   getwordPos $line $pos3 "Planets :"
   getwordPos $line $pos4 "Traders :"
   getwordPos $line $pos5 "Fighters:"
   getwordPos $line $pos6 " Armid)"

   if ($pos0 > 0)
      goto :sectorDone
   elseif ($pos1 > 0)                               // get sector number
      getword $line $sector 3
   elseIf ($pos2 > 0)                               // get port type
       getText $line $portType "(" ")"
       setVar $sectorInfo[$sector][1] $portType
   elseif ($pos3 > 0)                               // detected a planet
      setVar $sectorInfo[$sector][2] "Planet"       // not set for multiple detects in same sector
   elseif ($pos4 > 0)
       cutText $line $sectorInfo[$sector][3] 10 999
   elseif ($pos5 > 0)                               // check for fighters
      getwordpos $line $pos "belong to your Corp"   // do they belong to us
      if ($pos = 0)                                 // (did not check for pers)
         getword $line $sectorInfo[$sector][4] 2    // get how many
      end
   elseif ($pos6 > 0)                               // checking for Armid mines
      getwordpos $line $pos "belong to your Corp"   // do they belong to us?
      if ($pos = 0)
         getword $line $sectorInfo[$sector][5] 3
      end
   end
   setTextLineTrigger sectorLine :sectorLine
   pause

  :sectorDone
  # just so you can check the variable dump.        // no need to kill trigger
   waitfor "xyzzy"                                  // it kills itself

_________________
               / Promethius / Enigma / Wolfen /

"A man who has no skills can be taught, a man who has no honor has nothing."


Mon Oct 17, 2011 1:28 am
Profile ICQ
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1133
Location: Augusta, GA
Unread post Re: Simple Holo Script
The speed difference from using individual triggers is likely imperceptible, but it would be faster. You are doing the text parsing and matching for all of your triggers by hand really, which is the same thing TWX would do for you if you set individual triggers. It is nice to try alternate ways of writing scripts though. I prefer individual triggers and their corresponding :label-parse-pause, which would still require a list of killtriggers for something like this, where every trigger will not necessarily match.

I'm curious though, what idea of RammaR's is this based off of? Do you mean parsing for text matches by hand vs. triggers?

_________________
Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.


Mon Oct 17, 2011 7:06 am
Profile WWW
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post Re: Simple Holo Script
ElderProphet wrote:
...
I'm curious though, what idea of RammaR's is this based off of? Do you mean parsing for text matches by hand vs. triggers?


Yeah, parsing manually. I had never thought of trying that vs using triggers for something like a holoscan. I was reading his code for his probe script and noticed he didn't have the standard triggers set when the probe went through a sector. I thought for a special purpose it might work well.

I have finally started rewriting the 30-40 or so primary scripts I use, and have been reading other peoples scripts for ideas on different ways of doing things. I haven't been efficient in maintaining code snippets for includes or copy/paste/modify so that is my first goal.

[Edit] The "//" comment ability is a great addition to TWX, thank you. [/Edit]
[Edit2] "Waitfor xyzzy" is appropriate because that is who I am always waiting on.... my wife's alias when she used to play TW in 89-91. I never won a game against her back then.[/Edit2]

_________________
               / Promethius / Enigma / Wolfen /

"A man who has no skills can be taught, a man who has no honor has nothing."


Mon Oct 17, 2011 11:55 am
Profile ICQ
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1133
Location: Augusta, GA
Unread post Re: Simple Holo Script
Are you familiar with the triggering technique I've preached on before? I think of it as trigger-driven script flow. It's not the best technique under all circumstances, but I believe it's ideal for something like this. What is unique about this technique is that there is no main routine where script flow keeps returning to, for triggers to be killed and reset. Rather, triggers fire and reset themselves, so management is decentralized, kinda like an Object Oriented approach vs. linear flow.
Code:
:holoScan
send "sh"
waitOn "Long Range Scan"
setTextLineTrigger hsSector :hsSector "Sector  : "
setTextLineTrigger hsPorts :hsPorts "Ports   :"
setTextLineTrigger hsPlanets :hsPlanets "Planets :"
setTextLineTrigger hsTraders :hsTraders "Traders :"
setTextLineTrigger hsFighters :hsFighters "Fighters:"
setTextTrigger hsDone :hsDone "Command ["
pause

:hsSector
getWord CURRENTLINE $sector 3
setTextLineTrigger hsSector :hsSector "Sector  : "
pause

:hsPorts
getText CURRENTLINE $portType "(" ")"
setVar $sectorInfo[$sector][1] $portType
setTextLineTrigger hsPorts :hsPorts "Ports   :"
pause

:hsPlanets
setVar $sectorInfo[$sector][2] "Planet"
setTextLineTrigger hsPlanets :hsPlanets "Planets :"
pause

:hsTraders
cutText CURRENTLINE $sectorInfo[$sector][3] 10 999
setTextLineTrigger hsTraders :hsTraders "Traders :"
pause

:hsFighters
getwordpos CURRENTLINE $pos "belong to your Corp"
if ($pos = 0)
   getWord CURRENTLINE $sectorInfo[$sector][4] 2
end
setTextLineTrigger hsFighters :hsFighters "Fighters:"
pause

:hsDone
killTrigger hsSector
killTrigger hsPorts
killTrigger hsPlanets
killTrigger hsTraders
killTrigger hsFigs
# script continues here

Years ago, I saw a script by a corp called Defenders of the Universe, and they had a script that used a rudimentary version of this technique. At that time, I couldn't understand how it was even working, as it was unlike anything I'd seen. It took me a while to understand it, because everything else I'd seen followed a basic pattern of: set all triggers, pause, fire and parse, killAlllTriggers, go back to set all triggers.

To anyone reading this thread that doesn't understand the above code, do yourself a favor and ask questions and figure it out. If nothing else, you'll walk away with a much better understanding of how triggers work.

+EP+

_________________
Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.


Sun Oct 23, 2011 8:27 pm
Profile WWW
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post Re: Simple Holo Script
Yep, and that is the basic way my normal holo script is written. I am currently rewriting all of my primary scripts, and playing with different ways of doing things. Sometimes what I try I really like, and other times I just move the file to revisit later. Doing this has given me some ideas on different types of scripts that I personally haven't seen or encountered. The interesting part will be when I test the new ones against the old ones.

_________________
               / Promethius / Enigma / Wolfen /

"A man who has no skills can be taught, a man who has no honor has nothing."


Sun Oct 23, 2011 8:50 pm
Profile ICQ
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: Bing [Bot] and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by wSTSoftware.