www.ClassicTW.com
https://mail.black-squirrel.com/

2_Worldtrade.ts
https://mail.black-squirrel.com/viewtopic.php?f=15&t=26319
Page 1 of 1

Author:  Timberwolf [ Mon Jul 05, 2010 6:21 pm ]
Post subject:  2_Worldtrade.ts

I need to add some coding to the 2_Worldtrade.ts script that came with TWX proxy that would terminate the script if I get too low on turns, say 50 turns. I was using it today and I looked away for a minute and when I looked back my turns was down to zero. Thankfully no one else was on and I patiently waited for my turns to come back at the top of the hour and limped home.

I also need to use this same coding for a custom colonizing script that I'm writing. I want that script to terminate as well if the turns get too low.

I'm told Mombot will monitor that, but I think Mombot only monitors its own scripts and not the outside scripts. I could be wrong. I did have Mombot running when I ran this worldtrade script and it was set for 50 turns, but I guess that didn't work.

Any help is appreciated and thank you.

Author:  Helix [ Mon Jul 05, 2010 7:44 pm ]
Post subject:  Re: 2_Worldtrade.ts

so something like if turns > 51 continue, else halt?

so you would have to get the number of turns, throw them in a variable. Where would you want to do the check? Before porting? Before moving? After porting? All of those?

Lets work out the algorithm then put it together.

<digging out the script.html>

setVar $t = 0 //set turns variable to 0
//get current turns however (maybe using / to grab the current number of turns), then
$t = $ct //turns = current turns
IF ($t =< 50) // if the turns are greater than fifty one
HALT
ELSE
//continue trading
END

H

Author:  Timberwolf [ Mon Jul 05, 2010 7:51 pm ]
Post subject:  Re: 2_Worldtrade.ts

I would have to say after porting and before moving to the next port.

That line would be similar to what I have in mind.

Author:  Vid Kid [ Mon Jul 05, 2010 9:31 pm ]
Post subject:  Re: 2_Worldtrade.ts

Since you mentioned you are using mom bot , you can loadvar unlim
determine if its true or false ...

If false & not "0"
Get user input st (stop at turns)
use the include playerinfo
and pull your turns with a gosub to it
set var ct (current turns)

Else
setvar ct 99999
End

then in begining of work loop

gosub playerinfo
set ct playerinfo~turns
IF ($ct <= $st)
echo "*reached turn limit of "& $ct
halt
end

/ rest of script here

Author:  Kaus [ Mon Jul 05, 2010 9:45 pm ]
Post subject:  Re: 2_Worldtrade.ts

if you dont want to depend on mombot (while easier) you could use dynarri's quickstats found at http://www.navhaz.com (opensource).

Then you just check against that the quickstats routine.

#Set your minimum turn variable with a number
SetVar $MinimumTurns 50

#beginning code prior your check

#goto subroutine quickstats
gosub :quickstats

#If minimumturns less than or equal to your quickstats routine which uses / to get your turn data
#Then echo your custom text and halt.
if ($MinimumTurns <= $Quickstats[TURNS])
Echo ANSI_12 "**Halting due to minimum turn threshold"
halt
end

#---Subs
:quickstats
#The quickstats routine (I use Dynarri's) goes here

#Return to the main code
return

Author:  Helix [ Mon Jul 05, 2010 10:48 pm ]
Post subject:  Re: 2_Worldtrade.ts

Since Sing does't have it as a stand alone .ts file, I pulled it out of one of the dny scripts

# -------------------------------------------------------------------
# Quickstats routine by Dnyarri. A simple way to parse the slash stats
# into something useful.
# -------------------------------------------------------------------

:do_quickstats
killtrigger statlinetrig
setVar $stats ""
setTextLineTrigger statlinetrig :statsline #179
send "/"
pause

: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:  Kaus [ Mon Jul 05, 2010 11:12 pm ]
Post subject:  Re: 2_Worldtrade.ts

Helix wrote:
Since Sing does't have it as a stand alone .ts file, I pulled it out of one of the dny scripts


My bad I thought it was in a standalone version. Either way quickstats is my preferred method to pull player stats as it doesn't depend on any single script loading right. Off topic personally I like to leave the authors headers in, reminds me who to thank for the routine :-)

/Double offtopic sorta: is the mombot unlimited check variable named $Unlim and is it a SaveVar?

P.s. I recommend both using TWXIDE.exe as the text editor (I recommend it highly) or using http://www.navhaz.com/files/script.html
as reference for your colonizing script. Makes life much easier to have a quick reference that you don't have to load from within a script directory.

Author:  Vid Kid [ Mon Jul 05, 2010 11:47 pm ]
Post subject:  Re: 2_Worldtrade.ts

My mention of the mom bot was as to the .cfg variable it saved for the Unlim status.

and to use it , you
LoadVar $Unlim (as mentioned by someone above)

and as for the quick stats , that would add alot of extra code to your script verses

Gosub : PlayerInfo~InfoQuick
SetVar $ActualTurns $PlayerInfo~Turns


just my prefs.

Author:  booger [ Tue Jul 06, 2010 12:07 am ]
Post subject:  Re: 2_Worldtrade.ts

while i see why you would do this, i dont run 2_worldtrade if im AFK. it can get you podded...

Author:  Timberwolf [ Tue Jul 06, 2010 12:20 am ]
Post subject:  Re: 2_Worldtrade.ts

That it does, Booger. It's so fast that I looked away for a moment when I was down to about 200 turns and a moment was all it took for me to get right down to zero. Crap happens :)

Anyways, I appreciate the effort from all of you for providing the code snippets. Thanks :)

Author:  booger [ Tue Jul 06, 2010 12:26 am ]
Post subject:  Re: 2_Worldtrade.ts

that fast? wow your system must be smoking... i try to stay out of turn games too... so tha tisnt an issue as much...

Author:  Timberwolf [ Tue Jul 06, 2010 12:38 am ]
Post subject:  Re: 2_Worldtrade.ts

I remember the old days when it would take me a while to run 700-1000 turns on dial up and with slow scripts (TWAR for Windows anyone?)

Now these days, I can blow through 1000-1500 turns in no time at all.

I can see why high turn games are so prevalent these days.

But once again, thanks for the snippets, guys. I'm heading to bed and will look at them tomorrow :)

Author:  Parrothead [ Sun Oct 17, 2010 4:42 pm ]
Post subject:  Re: 2_Worldtrade.ts

Mombot :quikstats goes into endless loop under certain conditions

turns = 0...turns game...at least it does in the beta twgs

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/