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



Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
 Port upgrader 
Author Message
Ensign

Joined: Sun Mar 06, 2011 12:22 am
Posts: 205
Unread post Port upgrader
I made a script to upgrade ports, but it seems to do everything but what I want:

Code:
send "o3"
waitFor "How many units do you want to invest?"
setVar $toUpgrade1 CURRENTLINE
stripText $toUpgrade1 "("
getWord $toUpgrade1 $toUpgrade 9
send $toUpgrade "*"
send "o2"
waitFor "How many units do you want to invest?"
setVar $toUpgrade2 CURRENTLINE
stripText $toUpgrade1 "("
getWord $toUpgrade1 $toUpgrade 9
send $toUpgrade "*"
send "o1"
waitFor "How many units do you want to invest?"
setVar $toUpgrade3 CURRENTLINE
stripText $toUpgrade1 "("
getWord $toUpgrade1 $toUpgrade 9
send $toUpgrade "*"
if ($toUpgrade > 0)
  send "q"
end


It sends "0" or "00" whether or not the port is fully upgraded for that product, and it sends a "q" at the end even when $toUpgrade is zero.

_________________
Photons away!


Tue Mar 22, 2011 11:27 am
Profile
Commander

Joined: Sun Feb 25, 2001 3:00 am
Posts: 1838
Location: Guam USA
Unread post Re: Port upgrader
Quote:
send "o3"
waitFor "How many units do you want to invest?"
setVar $toUpgrade1 CURRENTLINE
stripText $toUpgrade1 "("
getWord $toUpgrade1 $toUpgrade 9
send $toUpgrade "*"
send "o2"
waitFor "How many units do you want to invest?"
setVar $toUpgrade2 CURRENTLINE
stripText $toUpgrade1 "("
getWord $toUpgrade1 $toUpgrade 9
send $toUpgrade "*"
send "o1"
waitFor "How many units do you want to invest?"
setVar $toUpgrade3 CURRENTLINE
stripText $toUpgrade1 "("
getWord $toUpgrade1 $toUpgrade 9
send $toUpgrade "*"
if ($toUpgrade > 0)
send "q"
end


Here is what I would do .. without testing .. changes made

send "o3"
waitOn "How many units do you want to invest?"
setVar $toUpgrade1 CURRENTLINE
getWord $toUpgrade1 $toUpgrade 9
stripText $toUpgrade "("
send $toUpgrade "**"
send "o2"
waitOn "How many units do you want to invest?"
setVar $toUpgrade2 CURRENTLINE
getWord $toUpgrade2 $toUpgrade 9
stripText $toUpgrade "("
send $toUpgrade "**"
send "o1"
waitOn "How many units do you want to invest?"
setVar $toUpgrade3 CURRENTLINE
getWord $toUpgrade3 $toUpgrade 9
stripText $toUpgrade "("
send $toUpgrade "**"
Send "cr*q"

Hope this helps

_________________
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


Tue Mar 22, 2011 12:42 pm
Profile WWW
Ensign

Joined: Sun Mar 06, 2011 12:22 am
Posts: 205
Unread post Re: Port upgrader
So, you changed WaitFor to WaitOn and stripTexted before getWording?

Sadly, it is still not upgrading anything. Thanks, though!

_________________
Photons away!


Tue Mar 22, 2011 4:45 pm
Profile
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post Re: Port upgrader
You might think of using arrays. Something like what is below that is not tested, but just to give you a thought on arrays:

Code:
setVar $i 3
While ($i > 0)
  send "o" $i
  waitOn "How many units do you want to invest?"
  getword currentline $toUpGrade 9
  stripText $toUpgrade "("
  send $toUpgrade "*"
  subtract $i 1
end
send "*cr*q"

_________________
               / Promethius / Enigma / Wolfen /

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


Tue Mar 22, 2011 4:52 pm
Profile ICQ
Veteran Op
User avatar

Joined: Sat Dec 29, 2007 5:06 pm
Posts: 2059
Location: Oklahoma
Unread post Re: Port upgrader
If you try upping a port that has already been upped this one will try all then then stop. Could add a CN check first and make sure you have minimum $5M credits it you will not have enough cash. I upped 4 ports for a test and it was approx $4.96M each.

Code:
# Port Upgrader

setvar $cat 3
setvar $wait "How many units do you want to invest?"
:top
send "o"
:go
send $cat
waitfor $wait
getWord CURRENTLINE $toUpgrade 9
stripText $toUpgrade "("
if ($toUpgrade > "0")
   send $toUpgrade "*"
   gosub :check
   goto :go
else
   send "0 *"
   gosub :check
   goto :top
end

:check
subtract $cat 1
if ($cat = "0")
   send "q"
   send "cr*q"
   waitfor "Command [TL"
   echo ANSI_15 "**Port Upgraded!!"
   halt
end
return

_________________
T0yman (Permanently Retired since 2012)
Proverbs 17:28 <-- Don't know it, most should it would stop a lot of the discussions on here.


Tue Mar 22, 2011 7:46 pm
Profile ICQ YIM WWW
Ensign

Joined: Sun Mar 06, 2011 12:22 am
Posts: 205
Unread post Re: Port upgrader
TOyman, I really appreciate your help, somehow it worked for you, but not for me:

Command [TL=00:00:00]:[8524] (?=Help)? : O
<Construct Starbase>

(Upgrade StarPort)


ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
º Upgrade Starport Production º
ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º 1 Fuel Ore, costs $250/unit º
º 2 Organics, costs $500/unit º
º 3 Equipment, costs $900/unit º
ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º Choose 1, 2, 3 or Q to quit º
ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
Choice ? 3

That will cost 900 per unit to upgrade the Equipment
How many units do you want to invest? (0 max, 0 to quit) 0

Command [TL=00:00:00]:[8524] (?=Help)? : O
<Construct Starbase>

(Upgrade StarPort)


ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
º Upgrade Starport Production º
ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º 1 Fuel Ore, costs $250/unit º
º 2 Organics, costs $500/unit º
º 3 Equipment, costs $900/unit º
ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º Choose 1, 2, 3 or Q to quit º
ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
Choice ? 2

That will cost 500 per unit to upgrade the Organics
How many units do you want to invest? (5668 max, 0 to quit) 0

Command [TL=00:00:00]:[8524] (?=Help)? : O
<Construct Starbase>

(Upgrade StarPort)


ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
º Upgrade Starport Production º
ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º 1 Fuel Ore, costs $250/unit º
º 2 Organics, costs $500/unit º
º 3 Equipment, costs $900/unit º
ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º Choose 1, 2, 3 or Q to quit º
ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
Choice ? 1

That will cost 250 per unit to upgrade the Fuel Ore
How many units do you want to invest? (0 max, 0 to quit)

Port Upgraded!!
Script terminated: scripts\0.ts



Command [TL=00:00:00]:[8524] (?=Help)? : Q
<Quit>
Confirmed? (Y/N)? No

Command [TL=00:00:00]:[8524] (?=Help)? : Q
<Quit>
Confirmed? (Y/N)?

Sect 8524³Turns 59,993³Creds 210,570,067³Figs 100,000³Shlds 13,082³Hlds 255
Ore 150³Org 0³Equ 0³Col 0³Phot 0³Armd 2³Lmpt 90³GTorp 4³TWarp 2³Clks 17
Beacns 600³AtmDt 16³Crbo 0³EPrb 61³MDis 0³PsPrb Yes³PlScn Yes³LRS Holo
Aln 1,710,823³Exp 270,319³Corp 1³Ship 7 TkhOri

Confirmed? (Y/N)?

This is driving me crazy!

_________________
Photons away!


Tue Mar 22, 2011 8:47 pm
Profile
Lieutenant Commander
User avatar

Joined: Sun Jan 29, 2006 3:00 am
Posts: 800
Location: Iowa
Unread post Re: Port upgrader
well..I can't help but go for the cheap answer:
[botname] maxport f,o,e ... have mom do it!
Even st-109 had a maxport function.

Ok, ok..here's my code snippet.


Code:
# rewrite of Grey's Port Upgrader
setVar $comodity 1
:cycle
  send "o" & $comodity
  waitFor "How many units do you want to invest?"
:howMany
setVar $toUpgrade CURRENTLINE
stripText $toUpgrade "("
getWord $toUpgrade $amount 9
  If $amount = 0
    send "*"
    goto :next
  End

send $amount & "*/*"

:next
waitfor "Command"
If $comodity < 3
  setvar $comodity $comodity + 1
  goto :cycle
End
echo Ansi_15 & "* Finished upgrading. *"
halt


worked for me..but i had a ton of cash. I put in for a maxed category.

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


Last edited by Crosby on Tue Mar 22, 2011 9:00 pm, edited 1 time in total.



Tue Mar 22, 2011 8:56 pm
Profile ICQ YIM
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post Re: Port upgrader
Post your current code?

_________________
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


Tue Mar 22, 2011 8:56 pm
Profile ICQ WWW
Veteran Op
User avatar

Joined: Sat Dec 29, 2007 5:06 pm
Posts: 2059
Location: Oklahoma
Unread post Re: Port upgrader
Change the following section, this will add a pause once it stops there, make sure no other scripts are running and run $sv "enter" or if you have scripts running it is $sv cat then we can see what variable it is catching. by your listing above variable cat should = 5668. I am running this on the beta so I am not sure on another version. To stop once you see the variable $z will terminate the script.

Code:
if ($cat = "1")
   echo ANSI_15 $cat
   pause
   send "q"
   send "cr*q"
   waitfor "Command [TL"
   echo ANSI_15 "**Port Upgraded!!"
   halt
end
return

_________________
T0yman (Permanently Retired since 2012)
Proverbs 17:28 <-- Don't know it, most should it would stop a lot of the discussions on here.


Tue Mar 22, 2011 9:21 pm
Profile ICQ YIM WWW
Commander

Joined: Sun Feb 25, 2001 3:00 am
Posts: 1838
Location: Guam USA
Unread post Re: Port upgrader
ok , I see now one reason you may have problems .. your using a fast computer and a :

WaitOn "How many units do you want to invest? "

needs to be changed to :

WaitOn ", 0 to quit)"

this way the CURRENTLINE will contain the value you seek.

and please use a real name for your file....

not numbers ...

I think all the scripts would work with this fix .. try them and tell us ;)

_________________
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


Tue Mar 22, 2011 10:00 pm
Profile WWW
Lieutenant Commander
User avatar

Joined: Sun Jan 29, 2006 3:00 am
Posts: 800
Location: Iowa
Unread post Re: Port upgrader
ahh nice one Vid!

So, to turn this into a teaching thread? Are you saying a fast computer will blaze past that line?
So maybe better to synch up with a 'Waitfor/Waiton' at "per unit to upgrade the" on the line
above it, then another waitfor or trigger?

kicks virtual pebble... Mine worked ok for me :roll:

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


Tue Mar 22, 2011 10:24 pm
Profile ICQ YIM
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1134
Location: Augusta, GA
Unread post Re: Port upgrader
It isn't a question of a fast computer or not. Good scripting technique will avoid problems whether the computer is fast or not. Let me explain the problem Vid is addressing. GG is using the following code:
Code:
send "o3"
waitFor "How many units do you want to invest?"
setVar $toUpgrade1 CURRENTLINE
stripText $toUpgrade1 "("
getWord $toUpgrade1 $toUpgrade 9

And here is the line he's trying to use getWord on:
How many units do you want to invest? (6390 max, 0 to quit)

Now from the code snippet, the waitFor trigger will fire after "invest?", and that is the 8th word in that line. But then he uses getWord to extract word 9. Now many times this will work, but if a packet happens to contain word 8 but not word 9, then a waitFor trigger constructed like this one will fire, but getWord will fail to pull the right data.

Use a setTextLineTrigger when possible, or trigger on unique text that occurs later in the text line than the data you are interested in. Here you can't use setTextLineTrigger because the line he's interested in is waiting on input (and therefore isn't followed by CRLF), so you need to use the 2nd option, and trigger off of something unique and after the desired text, like what Vid mentioned, ", 0 to quit)".

Having said all of that, I've not really studied the code and don't know if this is the real problem or not. But it is a potential problem and will cause problems or bugs that are hard to track down.

+EP+

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


Tue Mar 22, 2011 11:00 pm
Profile WWW
Lieutenant Commander
User avatar

Joined: Sun Jan 29, 2006 3:00 am
Posts: 800
Location: Iowa
Unread post Re: Port upgrader
ok, perhaps that's why my settextlinetrigger wasn't working. I didn't know about this whole CRLF biz. This is only on lines that the game is waiting on input from user?

I thought if you used settextlinetrigger, as I tried, using Gray's text "How many units do you want to invest?" it would grab the whole line. That's why you use a settextlinetrigger instead of a settexttrigger, right?

Anyway, apart from that, good scripting technique has us using the text past our target word for our trigger, ok?

ps Mine still worked. ( oh and note my use of 'ok' at the fore and aft of the verbal upchuck? wasted brilliance... )

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


Tue Mar 22, 2011 11:32 pm
Profile ICQ YIM
Commander

Joined: Sun Feb 25, 2001 3:00 am
Posts: 1838
Location: Guam USA
Unread post Re: Port upgrader
Thank you EP .. the SetTextLineTrigger or SetTextTrigger is better in most scripts.

I personally like to use text after my target , but I wanted to leave GG's script as close to his work
as possible .. otherwise I'de have just pasted my port upgrader.

I think its better to write your own , its a good learning experience.

I also find it nice to use a snippet test.ts to test parts of a script .. like a settextlinetrigger


Code:

:top
SetTextLineTrigger  have :have  ", 0 to quit)"
SetTextTrigger  havenot :havenot  ", 0 to quit)"
Pause

:have
Echo "**" ANSI_11 "LINE  worked*"
Halt

:havenot
Echo "**" ANSI_11 "NO LINE  worked*"
Halt




then type by hand to see which one works then fix up your script.
as things go on .. edit the text at the end of the SetText triggers.

hope this helps

_________________
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


Wed Mar 23, 2011 4:13 am
Profile WWW
Veteran Op
User avatar

Joined: Sat Dec 29, 2007 5:06 pm
Posts: 2059
Location: Oklahoma
Unread post Re: Port upgrader
I tested mine from work instead of a localhost connection and I found it was running to fast and not clearing as it should have on the $cat variable. I added a delay to slow it down 250ms seemed good but I bumped it a little since I was getting mixed results.
Could probably replace the gosub :delay to waitfor "Choice ?" and get same result.

Code:
# Port Upgrader

setvar $cat 3
setvar $wait "How many units do you want to invest?"
:top
send "o"
:go
gosub :delay
send $cat
waitfor $wait
getWord CURRENTLINE $toUpgrade 9
stripText $toUpgrade "("
if ($toUpgrade > "0")
   send $toUpgrade "*"
   gosub :check
   goto :go
else
   send "0 *"
   gosub :check
   goto :top
end

:check
subtract $cat 1
if ($cat = "0")
   send "q"
   waitfor "Command [TL"
   send "cr*q"
   waitfor "Command [TL"
   echo ANSI_15 "**Port Upgraded!!"
   halt
end
return

:delay
setdelaytrigger one :one 350
pause

:one
return

_________________
T0yman (Permanently Retired since 2012)
Proverbs 17:28 <-- Don't know it, most should it would stop a lot of the discussions on here.


Wed Mar 23, 2011 6:36 am
Profile ICQ YIM WWW
Display posts from previous:  Sort by  
Reply to topic   [ 20 posts ]  Go to page 1, 2  Next

Who is online

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