| www.ClassicTW.com https://mail.black-squirrel.com/ |
|
| Quick How To Question https://mail.black-squirrel.com/viewtopic.php?f=15&t=30374 |
Page 1 of 2 |
| Author: | V'Ger [ Wed Sep 22, 2010 10:02 pm ] |
| Post subject: | Quick How To Question |
I am trying to grab the current amount of ore in my holds from the / menu. I have compensated for grabbing the right field since its position may float, but sometimes when I do the getWord, the value is "255|Org". I tried to do a stripText "|Org" but that does not seem to solve it, so I am guessing that the | is really some different but being displayed as |. If someone could please tell me what to use in the stripText command I would greatly appreciate it. Thanks. |
|
| Author: | Crosby [ Wed Sep 22, 2010 10:10 pm ] |
| Post subject: | Re: Quick How To Question |
isn't | the same as #179 ? |
|
| Author: | Promethius [ Wed Sep 22, 2010 10:27 pm ] |
| Post subject: | Re: Quick How To Question |
Suggest that you take a look at the quickstats challenge thread. It will give you some good ideas. I believe Crosby is correct also. viewtopic.php?f=15&t=19424&p=171618&hilit=quickstats+challenge#p171618 |
|
| Author: | Big D [ Wed Sep 22, 2010 10:58 pm ] |
| Post subject: | Re: Quick How To Question |
Here's one way, altho I'm sure there are shortcuts to this proceedure because my twx skills are just good enough to get the final result. LOL send "/" waitfor "Ore" getWordPos CURRENTLINE $position "Ore" add $position 4 cutText CURRENTLINE $cut_line $position 3 getWord $cut_line $gas 1 replaceText $gas #179 "O" striptext $gas "O" striptext $gas "r" striptext $gas "g" echo "**" ansi_12 "Fuelore available = " $gas "*" halt Since you are only grabbing 3 digits (255 max) then this should work as a shorter version also send "/" waitfor "Ore" getWordPos CURRENTLINE $position "Ore" add $position 4 cutText CURRENTLINE $cut_line $position 3 getWord $cut_line $gas 1 replaceText $gas #179 "O" striptext $gas "O" echo "**" ansi_12 "Fuelore available = " $gas "*" halt |
|
| Author: | Singularity [ Wed Sep 22, 2010 11:28 pm ] |
| Post subject: | Re: Quick How To Question |
It's not the same | as the pipe symbol. It looks like that little 3. It's ascii #179. But yeh, use a general quickstats parser routine. Code: # ------------------------------------------------------------------- :do_quickstats killtrigger statlinetrig setVar $stats "" setTextLineTrigger statlinetrig :statsline #179 send "/" pause :process_stats setVar $stats "" :statsline killtrigger statlinetrig setVar $line CURRENTLINE replacetext $line #179 " " striptext $line "," setVar $stats $stats & $line getWordPos $line $pos "Ship" if ($pos > 0) goto :gotStats else setTextLineTrigger statlinetrig :statsline end pause :gotStats setVar $quickstats[SECT] 0 setVar $quickstats[TURNS] 0 setVar $quickstats[CREDS] 0 setVar $quickstats[FIGS] 0 setVar $quickstats[SHLDS] 0 setVar $quickstats[HLDS] 0 setVar $quickstats[ORE] 0 setVar $quickstats[ORG] 0 setVar $quickstats[EQU] 0 setVar $quickstats[COL] 0 setVar $quickstats[PHOT] 0 setVar $quickstats[ARMD] 0 setVar $quickstats[LMPT] 0 setVar $quickstats[GTORP] 0 setVar $quickstats[TWARP] 0 setVar $quickstats[CLKS] 0 setVar $quickstats[BEACNS] 0 setVar $quickstats[ATMDT] 0 setVar $quickstats[CRBO] 0 setVar $quickstats[EPRB] 0 setVar $quickstats[MDIS] 0 setVar $quickstats[PSPRB] "NO" setVar $quickstats[PLSCN] "NO" setVar $quickstats[LRS] "NONE" setVar $quickstats[ALN] 0 setVar $quickstats[EXP] 0 setVar $quickstats[CORP] 0 setVar $quickstats[SHIP] 0 setVar $quickstats[TYPE] 0 setVar $stats $stats & " @@@" upperCase $stats setVar $current_word 0 setVar $wordy "" while ($wordy <> "@@@") if ($wordy = "SECT") getWord $stats $quickstats[SECT] ($current_word + 1) elseif ($wordy = "TURNS") getWord $stats $quickstats[TURNS] ($current_word + 1) elseif ($wordy = "CREDS") getWord $stats $quickstats[CREDS] ($current_word + 1) elseif ($wordy = "FIGS") getWord $stats $quickstats[FIGS] ($current_word + 1) elseif ($wordy = "SHLDS") getWord $stats $quickstats[SHLDS] ($current_word + 1) elseif ($wordy = "HLDS") getWord $stats $quickstats[HLDS] ($current_word + 1) elseif ($wordy = "ORE") getWord $stats $quickstats[ORE] ($current_word + 1) elseif ($wordy = "ORG") getWord $stats $quickstats[ORG] ($current_word + 1) elseif ($wordy = "EQU") getWord $stats $quickstats[EQU] ($current_word + 1) elseif ($wordy = "COL") getWord $stats $quickstats[COL] ($current_word + 1) elseif ($wordy = "PHOT") getWord $stats $quickstats[PHOT] ($current_word + 1) elseif ($wordy = "ARMD") getWord $stats $quickstats[ARMD] ($current_word + 1) elseif ($wordy = "LMPT") getWord $stats $quickstats[LMPT] ($current_word + 1) elseif ($wordy = "GTORP") getWord $stats $quickstats[GTORP] ($current_word + 1) elseif ($wordy = "TWARP") getWord $stats $quickstats[TWARP] ($current_word + 1) elseif ($wordy = "CLKS") getWord $stats $quickstats[CLKS] ($current_word + 1) elseif ($wordy = "BEACNS") getWord $stats $quickstats[BEACNS] ($current_word + 1) elseif ($wordy = "ATMDT") getWord $stats $quickstats[ATMDT] ($current_word + 1) elseif ($wordy = "CRBO") getWord $stats $quickstats[CRBO] ($current_word + 1) elseif ($wordy = "EPRB") getWord $stats $quickstats[EPRB] ($current_word + 1) elseif ($wordy = "MDIS") getWord $stats $quickstats[MDIS] ($current_word + 1) elseif ($wordy = "PSPRB") getWord $stats $quickstats[PSPRB] ($current_word + 1) elseif ($wordy = "PLSCN") getWord $stats $quickstats[PLSCN] ($current_word + 1) elseif ($wordy = "LRS") getWord $stats $quickstats[LRS] ($current_word + 1) elseif ($wordy = "ALN") getWord $stats $quickstats[ALN] ($current_word + 1) elseif ($wordy = "EXP") getWord $stats $quickstats[EXP] ($current_word + 1) elseif ($wordy = "CORP") getWord $stats $quickstats[CORP] ($current_word + 1) elseif ($wordy = "SHIP") getWord $stats $quickstats[SHIP] ($current_word + 1) getWord $stats $quickstats[TYPE] ($current_word + 2) end add $current_word 1 getWord $stats $wordy $current_word end return # ------------------------------------------------------------------- |
|
| Author: | Vid Kid [ Thu Sep 23, 2010 12:00 am ] |
| Post subject: | Re: Quick How To Question |
I love the wheel and never plan to re-invent it .. So here is how I'de do it .... Code: Gosub :GetPlayerInfo SetVar $Ore $PlayerInfo~Ore SetVar $Holds $PlayerInfo~Holds IF (PORT.EXISTS[CURRENTSECTOR]) IF (PORT.BUYFUEL[CURRENTSECTOR] = FALSE) IF ($Ore < $Holds) Send "p*****" WaitOn "] (" End Else ClientMessage "No Gas in this sector , Shutting Down*" Sound failed Halt End Else ClientMessage "No Gas in this sector , Shutting Down*" Sound failed Halt End Halt #-=-=-=-=-includes-=-=-=-=- Include "include\playerInfo" #-=-=-=-=-=-=-=-=-=-=-=-=-= |
|
| Author: | V'Ger [ Thu Sep 23, 2010 6:46 am ] |
| Post subject: | Re: Quick How To Question |
Thanks all, greatly appreciate the help. |
|
| Author: | ElderProphet [ Thu Sep 23, 2010 8:33 pm ] |
| Post subject: | Re: Quick How To Question |
Vid, your post is calling a subroutine which I'm assuming is calling an included subroutine from PlayerInfo.ts, but that isn't apparent from your posted code and might be confusing. When I'm just looking for one item from the QuickStat display, I just do something like: Code: setTextLineTrigger qsHolds :getHolds "Hlds " pause :getHolds getText CURRENTLINE & #179 $holds "Hlds " #179 stripText $holds " " The only tricky bit to that is the getText CURRENTLINE & #179. You see, if Hlds is at the end of a quickstat line, then it will not be followed by #179, the | character. So I make sure that text I'm parsing with getText (CURRENTLINE & #179) will have a #179 at the end. |
|
| Author: | Singularity [ Thu Sep 23, 2010 8:53 pm ] |
| Post subject: | Re: Quick How To Question |
We had that little competition a while back. I've adapted mine and used it in a few spots. It's smaller than the above. Code: gosub :quickstats echo "*" echo $quickstats[SECT] & "*" echo $quickstats[TURNS] & "*" echo $quickstats[CREDS] & "*" echo $quickstats[FIGS] & "*" echo $quickstats[SHLDS] & "*" echo $quickstats[HLDS] & "*" echo $quickstats[ORE] & "*" echo $quickstats[ORG] & "*" echo $quickstats[EQU] & "*" echo $quickstats[COL] & "*" echo $quickstats[PHOT] & "*" echo $quickstats[ARMD] & "*" echo $quickstats[LMPT] & "*" echo $quickstats[GTORP] & "*" echo $quickstats[TWARP] & "*" echo $quickstats[CLKS] & "*" echo $quickstats[BEACNS] & "*" echo $quickstats[ATMDT] & "*" echo $quickstats[CRBO] & "*" echo $quickstats[EPRB] & "*" echo $quickstats[MDIS] & "*" echo $quickstats[PSPRB] & "*" echo $quickstats[PLSCN] & "*" echo $quickstats[LRS] & "*" echo $quickstats[ALN] & "*" echo $quickstats[EXP] & "*" echo $quickstats[CORP] & "*" echo $quickstats[SHIP] & "*" echo $quickstats[TYPE] & "*" # ------------------------------------------------------------------- halt # ------------------------------------------------------------------- :quickstats killTrigger stat_trigger setTextLineTrigger stat_trigger :grabSlashLine #179 & "Turns" send "/" pause :grabSlashLine setVar $stats_data " " :stat_line setVar $stats_data $stats_data & CURRENTLINE & " " getWordPos CURRENTLINE $pos1 "Ship" getWordPos CURRENTLINE $pos2 "?" if (($pos1 > 0) OR ($pos2 > 0)) goto :gotStats end killTrigger stat_trigger setTextLineTrigger stat_trigger :stat_line "" pause :gotStats killTrigger stat_trigger replaceText $stats_data #179 " " upperCase $stats_data stripText $stats_data "," setVar $stats "SECT TURNS CREDS FIGS SHLDS HLDS ORE ORG EQU COL PHOT ARMD LMPT GTORP TWARP CLKS BEACNS ATMDT CRBO EPRB MDIS PSPRB PLSCN LRS ALN EXP CORP SHIP %%%" setVar $stat_num 0 :pull_the_stat add $stat_num 1 getWord $stats $current_stat $stat_num if ($current_stat <> "%%%") setVar $quickstats[$current_stat] 0 getWordPos $stats_data $pos $current_stat cutText $stats_data $line $pos 999 getWord $line $quickstats[$current_stat] 2 if ($current_stat = "SHIP") getWord $line $quickstats[TYPE] 3 end goto :pull_the_stat end return # ------------------------------------------------------------------- |
|
| Author: | ElderProphet [ Fri Sep 24, 2010 6:17 pm ] |
| Post subject: | Re: Quick How To Question |
Sigh, I should just add quickstat parsing to TWX. Of course, that would render the age-old quickstat competition obsolete. |
|
| Author: | Singularity [ Fri Sep 24, 2010 7:36 pm ] |
| Post subject: | Re: Quick How To Question |
ElderProphet wrote: Sigh, I should just add quickstat parsing to TWX. Of course, that would render the age-old quickstat competition obsolete. Haha... well, that would still mean having to send a slash and wait for it to finish. |
|
| Author: | Big D [ Fri Sep 24, 2010 9:15 pm ] |
| Post subject: | Re: Quick How To Question |
ElderProphet wrote: Sigh, I should just add quickstat parsing to TWX. Of course, that would render the age-old quickstat competition obsolete. I think that would be a great idea. TWXSECTOR, TWXTURNS, TWXCREDITS. TWXFIGS, etc... |
|
| Author: | ElderProphet [ Mon Sep 27, 2010 6:01 pm ] |
| Post subject: | Re: Quick How To Question |
Singularity wrote: Haha... well, that would still mean having to send a slash and wait for it to finish. Yes. Yes it would. But then I wouldn't have to look at ugly 200-line quickstat routines anymore BigD, I was thinking QUICKSTAT.SECT, QUICKSTAT.TURNS, QUICKSTAT.CREDS, etc. |
|
| Author: | Tweety [ Tue Sep 28, 2010 1:03 am ] |
| Post subject: | Re: Quick How To Question |
then why not just add parsing for the player info screen too. and access player data with access variables like PLAYERINFO.ORE or parse more data, like clv and trader display to update a Player database. |
|
| Author: | Promethius [ Tue Sep 28, 2010 12:21 pm ] |
| Post subject: | Re: Quick How To Question |
Might as well add a telnet window and make it into something like SWATH while this is happening and then use a single helper with internal TWX scripting capability. Maybe run it in two modes, standard like it does now, or enhanced as a full blown helper. Use "twarp.locked $hitSector", "plock.locked $hitsector", "gridTo.mow $target", "fedKill.targeted $trader"......... But then where is the challenge in writing a script? Most people that write scripts get satisfaction out of figuring out how to do things for themselves; script users usually don't care about the mechanics, just that script_x does y. Why are scripting challenges something that script writers enjoy? |
|
| Page 1 of 2 | All times are UTC - 5 hours |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|