View unanswered posts | View active topics It is currently Mon Apr 20, 2026 3:22 pm



Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
 Quick How To Question 
Author Message
Gameop
User avatar

Joined: Tue Sep 25, 2007 7:27 pm
Posts: 530
Location: Long Island
Unread post 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.

_________________
If you have a building game, they will come...

Proud Sysop of ICE9 TWGS
Home of Building and Non Regulated Games
http://www.oregonsouth.com/ice9
telnet://ice9-tw.com:2002


Wed Sep 22, 2010 10:02 pm
Profile
Lieutenant Commander
User avatar

Joined: Sun Jan 29, 2006 3:00 am
Posts: 800
Location: Iowa
Unread post Re: Quick How To Question
isn't | the same as #179 ?

_________________
#+++
The early bird may get the worm, but the second mouse gets the cheese.
#---


Wed Sep 22, 2010 10:10 pm
Profile ICQ YIM
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post 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

_________________
               / Promethius / Enigma / Wolfen /

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


Wed Sep 22, 2010 10:27 pm
Profile ICQ
Veteran Op

Joined: Tue Nov 28, 2006 4:04 pm
Posts: 5025
Unread post 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


Wed Sep 22, 2010 10:58 pm
Profile
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post 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
# -------------------------------------------------------------------

_________________
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
Image


Wed Sep 22, 2010 11:28 pm
Profile ICQ WWW
Commander

Joined: Sun Feb 25, 2001 3:00 am
Posts: 1838
Location: Guam USA
Unread post 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"
#-=-=-=-=-=-=-=-=-=-=-=-=-=

_________________
TWGS V2 Vids World on Guam Port 2002
Telnet://vkworld.ddns.net:2002
Discord @ DiverDave#8374
Vid's World Discord

Founding Member -=[Team Kraaken]=- Ka Pla

Image
Winners of Gridwars 2010
MBN Fall Tournament 2011 winners Team Kraaken
Undisputed Champions of 2019 HHT Just for showing up!

The Oldist , Longist Running , Orginal Registered Owner of a TWGS server :
Vids World On Guam


Thu Sep 23, 2010 12:00 am
Profile WWW
Gameop
User avatar

Joined: Tue Sep 25, 2007 7:27 pm
Posts: 530
Location: Long Island
Unread post Re: Quick How To Question
Thanks all, greatly appreciate the help.

_________________
If you have a building game, they will come...

Proud Sysop of ICE9 TWGS
Home of Building and Non Regulated Games
http://www.oregonsouth.com/ice9
telnet://ice9-tw.com:2002


Thu Sep 23, 2010 6:46 am
Profile
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1134
Location: Augusta, GA
Unread post 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.

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


Thu Sep 23, 2010 8:33 pm
Profile WWW
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post 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

# -------------------------------------------------------------------

_________________
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
Image


Thu Sep 23, 2010 8:53 pm
Profile ICQ WWW
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1134
Location: Augusta, GA
Unread post 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.

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


Fri Sep 24, 2010 6:17 pm
Profile WWW
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post 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.

_________________
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
Image


Fri Sep 24, 2010 7:36 pm
Profile ICQ WWW
Veteran Op

Joined: Tue Nov 28, 2006 4:04 pm
Posts: 5025
Unread post 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...


Fri Sep 24, 2010 9:15 pm
Profile
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1134
Location: Augusta, GA
Unread post 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 :P

BigD, I was thinking QUICKSTAT.SECT, QUICKSTAT.TURNS, QUICKSTAT.CREDS, etc.

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


Mon Sep 27, 2010 6:01 pm
Profile WWW
Boo! inc.

Joined: Fri Jan 04, 2002 3:00 am
Posts: 221
Location: Canada
Unread post 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.


Tue Sep 28, 2010 1:03 am
Profile
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post 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?

_________________
               / Promethius / Enigma / Wolfen /

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


Tue Sep 28, 2010 12:21 pm
Profile ICQ
Display posts from previous:  Sort by  
Reply to topic   [ 16 posts ]  Go to page 1, 2  Next

Who is online

Users browsing this forum: No registered users and 20 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.