View unanswered posts | View active topics It is currently Thu Mar 28, 2024 3:26 am



Reply to topic  [ 6 posts ] 
 Improved Quick Stats Subroutine 
Author Message
Chief Warrant Officer
User avatar

Joined: Sat Feb 27, 2016 1:01 am
Posts: 193
Location: Molon Labe
Unread post Improved Quick Stats Subroutine
I have tested this a bit now and it seems to be working as intended, may still need a bit of tweaking concerning what prompt it activates on, though in most instances that would be the main prompt anyway. Consuming less than 35-lines, awesome!

Notes: Yes and No are converted to Boolean values and 'ITEM' simply refers to a capitalized value of the items within the quick-stats, if not found, TWX defaults the value to 0.


* See revision 2.02 below.


Code:
goSub :UPDATE_QSTATS

...

:UPDATE_QSTATS
#  Improved Quick Stats Subroutine  v1.00.  Update quick stat data as a dynamic array.  Use placeholder:  $_QSTATS[ITEM]
setVar $break 0
setVar $stat_line ""
send "/"
waitFor "Sect"
while ($break = 0)
  setVar $line CURRENTLINE
  getWord $line $ck_line 1
  if ($ck_line = "Command") OR ($ck_line = "Computer") OR ($ck_line = "<StarDock>")
   setVar $break 1
  else
   mergeText $stat_line $line $stat_line
   waitFor " "
  end
end

#  Parse and format data, e.g., data to Boolean, cleanup spaces, etc.
trim $stat_line
replaceText $stat_line #179 " "
stripText $stat_line ","
upperCase $stat_line
replaceText $stat_line "YES" 1
replaceText $stat_line "NO" 0

setVar $a 1
setVar $item ""
while ($item <> "SHIP")
getWord $stat_line $item $a
getWord $stat_line $data ($a + 1)
setVar $_QSTATS[$item] $data
add $a 2
end

return

#  END UPDATE_QSTATS

_________________
The object of life is not to be on the side of the majority, but to escape finding one’s self in the ranks of the insane.” — Marcus Aurelius

TWX Proxy Reference Online


Last edited by Adept on Sat Oct 01, 2016 1:59 am, edited 1 time in total.



Mon May 02, 2016 11:11 pm
Profile ICQ
Chief Warrant Officer
User avatar

Joined: Sat Feb 27, 2016 1:01 am
Posts: 193
Location: Molon Labe
Unread post Re: Improved Quick Stats Subroutine
This compacted revision is more functional, removing the restrictions of the earlier version (tested now in several scripts and thus far has always returned the needed data):

Code:
:QSTATS
#  Improved Quick Stats Subroutine  v2.01.  Update quick stat data as a dynamic array.  Use placeholder:  $_QSS[ITEM]
setVar $break 0
setVar $qss_line ""
send "/"
waitFor "Sect"
while ($break = 0)
setVar $line CURRENTLINE
getWordPos $line $break "Ship"
setVar $qss_line $qss_line & $line
waitFor " "
end
replaceText $qss_line #179 " "
stripText $qss_line ","
upperCase $qss_line
replaceText $qss_line "YES" 1
replaceText $qss_line "NO" 0
setVar $iqss 1
setVar $item ""
while ($item <> "SHIP")
getWord $qss_line $item $iqss
getWord $qss_line $data ($iqss + 1)
setVar $_QSS[$item] $data
add $iqss 2
end
return
#  END QSTATS

_________________
The object of life is not to be on the side of the majority, but to escape finding one’s self in the ranks of the insane.” — Marcus Aurelius

TWX Proxy Reference Online


Last edited by Adept on Sat Jun 18, 2016 4:20 am, edited 2 times in total.



Tue Jun 14, 2016 1:13 am
Profile ICQ
Gameop
User avatar

Joined: Tue Nov 19, 2002 3:00 am
Posts: 1050
Location: USA
Unread post Re: Improved Quick Stats Subroutine
Elegant approach, thanks for sharing.

*thumbs up*

_________________
Dark Dominion TWGS
Telnet://twgs.darkworlds.org:23
ICQ#31380757, -=English 101 pwns me=-
"This one claims to have been playing since 1993 and didn't know upgrading a port would raise his alignment."


Fri Jun 17, 2016 10:38 am
Profile ICQ
Chief Warrant Officer
User avatar

Joined: Sat Feb 27, 2016 1:01 am
Posts: 193
Location: Molon Labe
Unread post Re: Improved Quick Stats Subroutine
Mucho gracias.

* I made just one small change to make the counter more unique to prevent any conflicts when used in a loop.

_________________
The object of life is not to be on the side of the majority, but to escape finding one’s self in the ranks of the insane.” — Marcus Aurelius

TWX Proxy Reference Online


Sat Jun 18, 2016 4:19 am
Profile ICQ
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1131
Location: Augusta, GA
Unread post Re: Improved Quick Stats Subroutine
Nice. We had a competition once upon a time to see who could write the shortest quickstats routine. Was a blast, and the smallest was insane, like 15 lines.

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


Fri Jul 01, 2016 9:49 pm
Profile WWW
Chief Warrant Officer
User avatar

Joined: Sat Feb 27, 2016 1:01 am
Posts: 193
Location: Molon Labe
Unread post Re: Improved Quick Stats Subroutine
Just a small revision to prevent endless looping when subroutine is called while other text is in motion:

Code:
:QSTATS
#  Improved Quick Stats Subroutine  v2.02.  Update quick stat data as a dynamic array.  Use placeholder:  $_QSS[ITEM]
setVar $break 0
setVar $qss_line ""
send "/"
waitFor #179 & "Creds"
while ($break = 0)
setVar $line CURRENTLINE
getWordPos $line $break "Ship"
setVar $qss_line $qss_line & $line
waitFor " "
end
replaceText $qss_line #179 " "
stripText $qss_line ","
upperCase $qss_line
replaceText $qss_line "YES" 1
replaceText $qss_line "NO" 0
setVar $iqss 1
setVar $item ""
while ($item <> "SHIP")
getWord $qss_line $item $iqss
getWord $qss_line $data ($iqss + 1)
setVar $_QSS[$item] $data
add $iqss 2
end
return
#  END QSTATS

_________________
The object of life is not to be on the side of the majority, but to escape finding one’s self in the ranks of the insane.” — Marcus Aurelius

TWX Proxy Reference Online


Thu Sep 22, 2016 5:12 am
Profile ICQ
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

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