| Author |
Message |
|
NjoY
Ensign
Joined: Mon Jul 23, 2007 6:20 pm Posts: 288 Location: United Kingdom
|
 GetVar from QuickStats
I'm a bit stuck....
I've been trying to take a value (Number of holds) from the QuickStats. But i'm not having much luck. I've looked through loads of scripts but that just confused me more... Is it formatted differently than "normal" or i thought i could be picking up some ansi code as well??
I can get the number of holds after sending "I" np but not the QuickStats.
Thanx in advance.
NjoY
_________________ Gul D'Tek (The Cardassian Hitman) ICQ - 446445340
I'm a TW and #SD# ing you was my idea!
Very funny, Scotty. Now beam down my clothes.~ J.T.Kirk
|
| Sun Jan 13, 2008 2:58 pm |
|
 |
|
Promethius
Ambassador
Joined: Mon Feb 09, 2004 3:00 am Posts: 3141 Location: Kansas
|
 Re: GetVar from QuickStats
There was a bit of a scripting challenge on this subject: http://www.classictw.com/viewtopic.php?f=15&t=19424&hilit=quickstatsThe quickstats line poses problems for various reasons - info showing up on different lines due to length of line changes (ship assets, experience and alignment may cause this), and not having a consistent ending text being two of them. If I remember correctly you may also have some information not show because your ship doesn't have that particular item - could be wrong on this part as it has been a while since I worked with quickstats - I have something that works and I'm not messing with it  . The information divider is an ANSI character and if you copy it from the game line and paste it into an ASCII/text editor you will see the difference. I think Singularity has worked with this a lot and may be able to shed more light for you and/or correct what I think are the problems.
_________________
/ Promethius / Enigma / Wolfen /
"A man who has no skills can be taught, a man who has no honor has nothing."
|
| Sun Jan 13, 2008 4:14 pm |
|
 |
|
Singularity
Veteran Op
Joined: Thu Jun 02, 2005 2:00 am Posts: 5558 Location: USA
|
 Re: GetVar from QuickStats
Yah, mostly it's just PHOT and CORP that don't appear if photons are disabled or you aren't on a corp.
Check that thread out.
_________________ May the unholy fires of corbomite ignite deep within the depths of your soul...
1. TWGS server @ twgs.navhaz.com 2. The NavHaz Junction - Tradewars 2002 Scripts, Resources and Downloads 3. Open IRC chat @ irc.freenode.net:6667 #twchan 4. Parrothead wrote: Jesus wouldn't Subspace Crawl.
*** SG memorial donations via paypal to: dpocky68@booinc.com
|
| Sun Jan 13, 2008 4:48 pm |
|
 |
|
LoneStar
Commander
Joined: Fri Jun 09, 2006 2:00 am Posts: 1401 Location: Canada
|
 Re: GetVar from QuickStats
You can try: Code: send "/" waitfor (#179 & "Hlds") getText CURRENTLINE $TOTAL_HOLDS (#179 & "Hlds") #179 stripText $TOTAL_HOLDS " "
if that's all your wanting to get from the qss I would strongly suggest using MindDagger's variation on Sing's QuikStats routine. I use it in all my scripts 
_________________ ---------------------------- -= QUANTUM Computing 101: 15 = 3 x 5 ... 48% of the time.
|
| Sun Jan 13, 2008 6:37 pm |
|
 |
|
Zarkahn
Lieutenant
Joined: Sat Nov 06, 2004 3:00 am Posts: 600 Location: USA
|
 Re: GetVar from QuickStats
personally, I use one of Sing's in most my scripts... Keeps all the vars the same script to script. Its not the one they were playing with for shorter code, but I was already using it and it works fine no need to change it... I just call it as a gosub and added a return to the end of it. I won't post it though, because its not my code to post.
_________________ Its not the Kill, Its the Thrill of the Chase
S: Min: 297 Max: 437 Average: 410 -- Just here to attack aliens
S: High/Low Removed Average: 421
|
| Mon Jan 14, 2008 8:14 am |
|
 |
|
Singularity
Veteran Op
Joined: Thu Jun 02, 2005 2:00 am Posts: 5558 Location: USA
|
 Re: GetVar from QuickStats
If it's the one in my scripts, it's public domain and can be found on my sigsite.
_________________ May the unholy fires of corbomite ignite deep within the depths of your soul...
1. TWGS server @ twgs.navhaz.com 2. The NavHaz Junction - Tradewars 2002 Scripts, Resources and Downloads 3. Open IRC chat @ irc.freenode.net:6667 #twchan 4. Parrothead wrote: Jesus wouldn't Subspace Crawl.
*** SG memorial donations via paypal to: dpocky68@booinc.com
|
| Mon Jan 14, 2008 9:15 am |
|
 |
|
LoneStar
Commander
Joined: Fri Jun 09, 2006 2:00 am Posts: 1401 Location: Canada
|
 Re: GetVar from QuickStats
Mind Dagger posted his a while back: viewtopic.php?f=15&t=18338&p=161745&hilit=quikstat#p161745Here it is again (as posted by MD), in case the link above doesn't work: Code: #Author: Mind Dagger #Gets player stats from the hitting the / key. Also grabs the current prompt that you are at. #The only prompt this will stall on is in the middle of chatting #gotStats routine by Dynarri/Singularity # ============================ START QUIKSTAT VARIABLES ========================== setVar $CURRENT_PROMPT "Undefined" setVar $PSYCHIC_PROBE "NO" setVar $PLANET_SCANNER "NO" setVar $SCAN_TYPE "NONE" setVar $CURRENT_SECTOR 0 setVar $TURNS 0 setVar $CREDITS 0 setVar $FIGHTERS 0 setVar $SHIELDS 0 setVar $TOTAL_HOLDS 0 setVar $ORE_HOLDS 0 setVar $ORGANIC_HOLDS 0 setVar $EQUIPMENT_HOLDS 0 setVar $COLONIST_HOLDS 0 setVar $PHOTONS 0 setVar $ARMIDS 0 setVar $LIMPETS 0 setVar $GENESIS 0 setVar $TWARP_TYPE 0 setVar $CLOAKS 0 setVar $BEACONS 0 setVar $ATOMIC 0 setVar $CORBO 0 setVar $EPROBES 0 setVar $MINE_DISRUPTORS 0 setVar $ALIGNMENT 0 setVar $EXPERIENCE 0 setVar $CORP 0 setVar $SHIP_NUMBER 0 setVar $TURNS_PER_WARP 0 setVar $COMMAND_PROMPT "Command" setVar $COMPUTER_PROMPT "Computer" setVar $CITADEL_PROMPT "Citadel" setVar $PLANET_PROMPT "Planet" setVar $CORPORATE_PROMPT "Corporate" setVar $STARDOCK_PROMPT "<Stardock>" setVar $HARDWARE_PROMPT "<Hardware" setVar $SHIPYARD_PROMPT "<Shipyard>" setVar $TERRA_PROMPT "Terra" # ============================ END QUIKSTAT VARIABLES ==========================
:quikstats setVar $CURRENT_PROMPT "Undefined" killtrigger noprompt killtrigger prompt1 killtrigger prompt2 killtrigger prompt3 killtrigger prompt4 killtrigger statlinetrig killtrigger getLine2 setTextTrigger prompt1 :primaryPrompts "(?=" setTextLineTrigger prompt2 :secondaryPrompts "(?)" setTextLineTrigger statlinetrig :statStart #179 setTextTrigger prompt3 :terraPrompts "Do you wish to (L)eave or (T)ake Colonists?" setTextTrigger prompt4 :terraPrompts "How many groups of Colonists do you want to take (" send "^Q/" pause
:PrimaryPrompts getWord currentansiline $checkPrompt 1 getWord currentline $tempPrompt 1 getWordPos $checkPrompt $pos #27&"[35m" if ($pos > 0) setVar $CURRENT_PROMPT $tempPrompt end setTextLineTrigger prompt1 :PrimaryPrompts "(?=" pause :secondaryPrompts getWord currentansiline $checkPrompt 1 getWord currentline $tempPrompt 1 getWordPos $checkPrompt $pos #27&"[35m" if ($pos > 0) setVar $CURRENT_PROMPT $tempPrompt end setTextLineTrigger prompt2 :secondaryPrompts "(?)" pause :terraPrompts killtrigger prompt3 killtrigger prompt4 getWord currentansiline $checkPrompt 1 getWordPos $checkPrompt $pos #27&"[35m" if ($pos > 0) setVar $CURRENT_PROMPT "Terra" end setTextTrigger prompt3 :terraPrompts "Do you wish to (L)eave or (T)ake Colonists?" setTextTrigger prompt4 :terraPrompts "How many groups of Colonists do you want to take (" pause
:statStart killtrigger prompt1 killtrigger prompt2 killtrigger prompt3 killtrigger prompt4 killtrigger noprompt setVar $stats "" setVar $wordy ""
:statsline killtrigger statlinetrig killtrigger getLine2 setVar $line2 CURRENTLINE replacetext $line2 #179 " " striptext $line2 "," setVar $stats $stats & $line2 getWordPos $line2 $pos "Ship" if ($pos > 0) goto :gotStats else setTextLineTrigger getLine2 :statsline pause end
:gotStats setVar $stats $stats & " @@@"
setVar $current_word 0 while ($wordy <> "@@@") if ($wordy = "Sect") getWord $stats $CURRENT_SECTOR ($current_word + 1) elseif ($wordy = "Turns") getWord $stats $TURNS ($current_word + 1) elseif ($wordy = "Creds") getWord $stats $CREDITS ($current_word + 1) elseif ($wordy = "Figs") getWord $stats $FIGHTERS ($current_word + 1) elseif ($wordy = "Shlds") getWord $stats $SHIELDS ($current_word + 1) elseif ($wordy = "Hlds") getWord $stats $TOTAL_HOLDS ($current_word + 1) elseif ($wordy = "Ore") getWord $stats $ORE_HOLDS ($current_word + 1) elseif ($wordy = "Org") getWord $stats $ORGANIC_HOLDS ($current_word + 1) elseif ($wordy = "Equ") getWord $stats $EQUIPMENT_HOLDS ($current_word + 1) elseif ($wordy = "Col") getWord $stats $COLONIST_HOLDS ($current_word + 1) elseif ($wordy = "Phot") getWord $stats $PHOTONS ($current_word + 1) elseif ($wordy = "Armd") getWord $stats $ARMIDS ($current_word + 1) elseif ($wordy = "Lmpt") getWord $stats $LIMPETS ($current_word + 1) elseif ($wordy = "GTorp") getWord $stats $GENESIS ($current_word + 1) elseif ($wordy = "TWarp") getWord $stats $TWARP_TYPE ($current_word + 1) elseif ($wordy = "Clks") getWord $stats $CLOAKS ($current_word + 1) elseif ($wordy = "Beacns") getWord $stats $BEACONS ($current_word + 1) elseif ($wordy = "AtmDt") getWord $stats $ATOMIC ($current_word + 1) elseif ($wordy = "Corbo") getWord $stats $CORBO ($current_word + 1) elseif ($wordy = "EPrb") getWord $stats $EPROBES ($current_word + 1) elseif ($wordy = "MDis") getWord $stats $MINE_DISRUPTORS ($current_word + 1) elseif ($wordy = "PsPrb") getWord $stats $PSYCHIC_PROBE ($current_word + 1) elseif ($wordy = "PlScn") getWord $stats $PLANET_SCANNER ($current_word + 1) elseif ($wordy = "LRS") getWord $stats $SCAN_TYPE ($current_word + 1) elseif ($wordy = "Aln") getWord $stats $ALIGNMENT ($current_word + 1) elseif ($wordy = "Exp") getWord $stats $EXPERIENCE ($current_word + 1) elseif ($wordy = "Corp") getWord $stats $CORP ($current_word + 1) elseif ($wordy = "Ship") getWord $stats $SHIP_NUMBER ($current_word + 1) end add $current_word 1 getWord $stats $wordy $current_word end :DoneQuikstats killtrigger prompt1 killtrigger prompt2 killtrigger prompt3 killtrigger prompt4 killtrigger statlinetrig killtrigger getLine2 return # ============================== END QUICKSTATS SUB==============================
Edited to remove those pesky '&nps;' thingys
_________________ ---------------------------- -= QUANTUM Computing 101: 15 = 3 x 5 ... 48% of the time.
|
| Mon Jan 14, 2008 12:44 pm |
|
 |
|
ElderProphet
Commander
Joined: Tue Oct 07, 2003 2:00 am Posts: 1134 Location: Augusta, GA
|
 Re: GetVar from QuickStats
Wow, that was my favorite thread of all time. An 11 line quickstat... who'd have thunk it?
So why would you recommend that 200 line routine above?
+EP+
_________________ Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.
|
| Mon Jan 14, 2008 1:06 pm |
|
 |
|
LoneStar
Commander
Joined: Fri Jun 09, 2006 2:00 am Posts: 1401 Location: Canada
|
 Re: GetVar from QuickStats
It handles prompts, and assigns Common variable names to quickstat results. If I had to choose between: if ($somearray[$i] <> "..whatever") ... & ... if ($CURRENT_PROMPT <> "..whatever") I'd choose the latter; alot easier to rememeber than indicies in an array; imho. In terms of Speed, if I need a current-sector, or some other snippet of qss, I try not to use a quikstat routine anyways (something like what I originally suggested at the top of this thread. Disclaimer: These are the opinions of a weekend warrior 'scripter'. Handle with care 
_________________ ---------------------------- -= QUANTUM Computing 101: 15 = 3 x 5 ... 48% of the time.
|
| Mon Jan 14, 2008 1:22 pm |
|
 |
|
Mind Dagger
Chief Warrant Officer
Joined: Wed Jan 04, 2006 3:00 am Posts: 136 Location: USA
|
 Re: GetVar from QuickStats
Here is the newest version I have, that grabs the current prompt with the built in way Lonestar found in the old twgs documentation. I like it better, but the old prompt code does have the advantage that it works in older twgs games (like ones in BBS's or so I hear) The advantage is it handles all prompts instead of needing to check which one it is like the older one: Code: #This is essentially Sing's code with the added prompt put in :quikstats setVar $CURRENT_PROMPT "Undefined" killtrigger noprompt killtrigger prompt killtrigger statlinetrig killtrigger getLine2 setTextLineTrigger prompt :allPrompts #145 & #8 setTextLineTrigger statlinetrig :statStart #179 send #145&"/" pause :allPrompts getWord CURRENTLINE $CURRENT_PROMPT 1 "Undefined" stripText $CURRENT_PROMPT #145 stripText $CURRENT_PROMPT #8 setTextLineTrigger prompt :allPrompts #145 & #8 pause :statStart killtrigger prompt setVar $stats "" setVar $wordy "" :statsline killtrigger statlinetrig killtrigger getLine2 setVar $line2 CURRENTLINE replacetext $line2 #179 " " striptext $line2 "," setVar $stats $stats & $line2 getWordPos $line2 $pos "Ship" if ($pos > 0) goto :gotStats else setTextLineTrigger getLine2 :statsline pause end :gotStats setVar $stats $stats & " @@@" setVar $current_word 0 while ($wordy <> "@@@") if ($wordy = "Sect") getWord $stats $CURRENT_SECTOR ($current_word + 1) elseif ($wordy = "Turns") getWord $stats $TURNS ($current_word + 1) elseif ($wordy = "Creds") getWord $stats $CREDITS ($current_word + 1) elseif ($wordy = "Figs") getWord $stats $FIGHTERS ($current_word + 1) elseif ($wordy = "Shlds") getWord $stats $SHIELDS ($current_word + 1) elseif ($wordy = "Hlds") getWord $stats $TOTAL_HOLDS ($current_word + 1) elseif ($wordy = "Ore") getWord $stats $ORE_HOLDS ($current_word + 1) elseif ($wordy = "Org") getWord $stats $ORGANIC_HOLDS ($current_word + 1) elseif ($wordy = "Equ") getWord $stats $EQUIPMENT_HOLDS ($current_word + 1) elseif ($wordy = "Col") getWord $stats $COLONIST_HOLDS ($current_word + 1) elseif ($wordy = "Phot") getWord $stats $PHOTONS ($current_word + 1) elseif ($wordy = "Armd") getWord $stats $ARMIDS ($current_word + 1) elseif ($wordy = "Lmpt") getWord $stats $LIMPETS ($current_word + 1) elseif ($wordy = "GTorp") getWord $stats $GENESIS ($current_word + 1) elseif ($wordy = "TWarp") getWord $stats $TWARP_TYPE ($current_word + 1) elseif ($wordy = "Clks") getWord $stats $CLOAKS ($current_word + 1) elseif ($wordy = "Beacns") getWord $stats $BEACONS ($current_word + 1) elseif ($wordy = "AtmDt") getWord $stats $ATOMIC ($current_word + 1) elseif ($wordy = "Corbo") getWord $stats $CORBO ($current_word + 1) elseif ($wordy = "EPrb") getWord $stats $EPROBES ($current_word + 1) elseif ($wordy = "MDis") getWord $stats $MINE_DISRUPTORS ($current_word + 1) elseif ($wordy = "PsPrb") getWord $stats $PSYCHIC_PROBE ($current_word + 1) elseif ($wordy = "PlScn") getWord $stats $PLANET_SCANNER ($current_word + 1) elseif ($wordy = "LRS") getWord $stats $SCAN_TYPE ($current_word + 1) elseif ($wordy = "Aln") getWord $stats $ALIGNMENT ($current_word + 1) elseif ($wordy = "Exp") getWord $stats $EXPERIENCE ($current_word + 1) elseif ($wordy = "Corp") getWord $stats $CORP ($current_word + 1) elseif ($wordy = "Ship") getWord $stats $SHIP_NUMBER ($current_word + 1) end add $current_word 1 getWord $stats $wordy $current_word end :doneQuikstats killtrigger statlinetrig killtrigger getLine2 return
I also do not enjoy grabbing stats from an array. I like to have the variables be clear and consistent in the code. Using strings to access the array would be another way to handle it, but I wanted the array to be static. I used to use global variables like: setVar $CURRENT_SECTOR 1 setVar $ARMID_MINES 2 etc.. And then call the stats like: $quikstats[$CURRENT_SECTOR] But I ended up just putting them in their own variables for simplicity's sake. I suppose it's all just a matter of taste. Oh, that quikstats routine thread was the best time I have ever had on this forum. Was great fun. MD
|
| Mon Jan 14, 2008 1:37 pm |
|
 |
|
LoneStar
Commander
Joined: Fri Jun 09, 2006 2:00 am Posts: 1401 Location: Canada
|
 Re: GetVar from QuickStats
Mind Dagger wrote: Here is the newest version I have, that grabs the current prompt with the built in way Lonestar found in the old twgs documentation. I like it better, but the old prompt code does have the advantage that it works in older twgs games (like ones in BBS's or so I hear)
Ack! ...you took out the Terra Prompt Check.
_________________ ---------------------------- -= QUANTUM Computing 101: 15 = 3 x 5 ... 48% of the time.
|
| Mon Jan 14, 2008 3:14 pm |
|
 |
|
Mind Dagger
Chief Warrant Officer
Joined: Wed Jan 04, 2006 3:00 am Posts: 136 Location: USA
|
 Re: GetVar from QuickStats
LoneStar wrote: Ack! ...you took out the Terra Prompt Check. Well currently I check for "How" or "Do" for the Terra prompts. It's not perfect, but it's worked for me so far. Just for additional fun, here's the subroutine I made for the bot that checks if you are in the correct prompt. This is for the mow command: Code: gosub :quikstats setVar $validPrompts "Command <Underground> Do How Corporate Citadel Planet Computer <StarDock> <FedPolice> <Tavern> <Libram <Galactic <Hardware <Shipyards>" gosub :checkStartingPrompt
:checkStartingPrompt setVar $startingLocation $CURRENT_PROMPT getWordPos " "&$validPrompts&" " $pos $startingLocation if ($pos <= 0) setVar $message "Invalid starting prompt: ["&$CURRENT_PROMPT&"]. Valid prompt(s) for this command: ["&$validPrompts&"]*" echo $message halt end return
MD
|
| Mon Jan 14, 2008 6:05 pm |
|
 |
|
NjoY
Ensign
Joined: Mon Jul 23, 2007 6:20 pm Posts: 288 Location: United Kingdom
|
 Re: GetVar from QuickStats
LoneStar wrote: You can try: Code: send "/" waitfor (#179 & "Hlds") getText CURRENTLINE $TOTAL_HOLDS (#179 & "Hlds") #179 stripText $TOTAL_HOLDS " "
if that's all your wanting to get from the qss I would strongly suggest using MindDagger's variation on Sing's QuikStats routine. I use it in all my scripts  Many thanx LS for the code. To be honest, i never used the code, i went for your suggestion about using MD's and Sings Quickstats Subroutine. Its awesome... then i upgraded to Md's newest version. Thanx MD. Thanks guys!! I came looking for help with a few lines of code and ended up learning a lot more. The "challenge" link was a good read. I enjoyed that thread. As for array's and pointers.... They make my brain hurt.... I prefer the simple things in life like women... and variables lol Take care ya'll and thanx again.
_________________ Gul D'Tek (The Cardassian Hitman) ICQ - 446445340
I'm a TW and #SD# ing you was my idea!
Very funny, Scotty. Now beam down my clothes.~ J.T.Kirk
|
| Tue Jan 15, 2008 1:37 pm |
|
 |
|
Zarkahn
Lieutenant
Joined: Sat Nov 06, 2004 3:00 am Posts: 600 Location: USA
|
 Re: GetVar from QuickStats
so EP enlighten us too lazy to look for it, what was the shortest lines for a quickstats rotinue? I thought ya'll had one down to under 20 lines?
_________________ Its not the Kill, Its the Thrill of the Chase
S: Min: 297 Max: 437 Average: 410 -- Just here to attack aliens
S: High/Low Removed Average: 421
|
| Tue Jan 15, 2008 8:37 pm |
|
 |
|
ElderProphet
Commander
Joined: Tue Oct 07, 2003 2:00 am Posts: 1134 Location: Augusta, GA
|
 Re: GetVar from QuickStats
1255. That is how many ifs the :gotStats routine in that revised code (no pun Res) has to execute w/ Corp and Phot present. You say you hate arrays, and I respect that. But they are efficient. Does it take TWX long to iterate over 1161 or 1255 if comparisons for a quickstat routine? No. But I don't think that is any reason not to write efficient code. With 2 or 3 minor changes, you can cut it down to 28 iterations, maintaining the exact same results, without arrays. Do you see why this is, and what the minor changes should be? +EP+ (P.S. Nice trigger-driven code at the beginning.  )
_________________ Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.
|
| Tue Jan 15, 2008 8:45 pm |
|
 |
|