View unanswered posts | View active topics It is currently Wed Apr 22, 2026 5:59 pm



Reply to topic  [ 71 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
 TWX 2.05 Beta 
Author Message
Veteran Op

Joined: Tue Nov 28, 2006 4:04 pm
Posts: 5025
Unread post Re: TWX 2.05 Beta
Actually I think you are both right in a sense. IF you are a programmer, added fuctions would actually make TWX easier to block and easier for a programmer to come back to at a later date and understand what's going on. However if these functions were used improperly by someone that doesn't have good programming skills, it could pose serious issues such as stacks, memory leaks, and system crashes.


Tue Jun 16, 2009 11:51 pm
Profile
Gameop
User avatar

Joined: Tue Nov 19, 2002 3:00 am
Posts: 1050
Location: USA
Unread post Re: TWX 2.05 Beta
Personally I think the biggest issue with newer people learning TWX is that it involves work. Sorry but thats my honest opinion, we live and play in a period where if it's not easy it's not worth doing. Ive been off and on learning TWX for quite awhile and sometimes I still dont get it all. That doesnt mean its the scripting languages fault, as someone who had limited prior experiance with languages some concepts were harder than others to grasp (BFS, Array's). But in the end dilegence and perseverance paid off and I understand them enough to incorporate them into scripts. Scripts are work, they take time/thought and patience to complete, something in my opinion allot of the newer and some older players lack.

_________________
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."


Wed Jun 17, 2009 9:46 am
Profile ICQ
Lieutenant Commander
User avatar

Joined: Thu Mar 21, 2002 3:00 am
Posts: 890
Location: USA
Unread post Re: TWX 2.05 Beta
I have some really short bits of BFS code that even I don't understand how they work anymore. Actually, I have quite a bit of code where I know what it does, but I'm not sure I understand it anymore. I was making changes to MoveHelper recently and basically had to start from scratch in a few places because it was easier to start over than figure out what I was doing in the first place. The advantage of doing that was that I was able to use some of the new stuff that EP put in.

My point is, you only get back what you put into it.

Jackalope, if you want to help EP, I'm sure he would welcome it. People have offered to help in the past too. But you have to understand that most TW players are flakes and once they realized the work involved, they bailed on him. Or they had their own vision for it and it conflicted with the direction EP was going. But you need to be serious, and you need to have a good grasp of the code.

If you really want to help, why not pick one or two of the changes yourself in the existing code and show it to EP. THAT would get his attention and show you were serious. Otherwise, you're all talk.

_________________
http://tw-cabal.navhaz.com - THE TW info site

Man, I gotta quit showing up here...next thing you know i'll get dragged back in.


Wed Jun 17, 2009 4:55 pm
Profile WWW
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1134
Location: Augusta, GA
Unread post Re: TWX 2.05 Beta
I have a lot to say about this subject (imagine that), but the long and short of it is this: I didn't understand why Xide limited TWX when I was a scipter, but I've come to see his vision since I took over, and I agree with it and perpetuate it. To understand what his vision was, you have to understand what makes TWX the helper of choice - scripts. Now understand what makes it the script engine of choice - simplicity. Now understand what makes it simple - goto statements and labels, and the lack of complex structures. How many of us know what this line of code does?
v.erase(remove_if(v.begin(), v.end(), [x, y](int n) { return x < n && n < y; }), v.end());

Exactly none of us. Sure, it would take 100 lines of TWX code to reproduce a C++ lambda function, but you'd be able to understand what was going on without 10 years of programming experience. And that is the point. No scripting language is trivial, but TWX is as simple as possible, so that non-programmers can write scripts. As evidence, I submit that more than 90% of the scripts on Grimy were written by non-programmers.

There has not been written a simpler scripting language to automate TradeWars play. If you'd like, I'd be happy to tell you the 20 most important TWX commands to learn, and that alone would give you the ability to write some basic scripts.

What TWX lacks is good documentation and tutorials. Instead of people getting on the bandwagon for TWX development, let someone spearhead a TWX documentation project, and make me one of the editors (to weed out misinformation). That would do far more for TWX and those trying to learn scripting than additional developers.

+EP+

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


Wed Jun 17, 2009 6:01 pm
Profile WWW
Gameop
User avatar

Joined: Tue Nov 19, 2002 3:00 am
Posts: 1050
Location: USA
Unread post Re: TWX 2.05 Beta
ElderProphet wrote:

What TWX lacks is good documentation and tutorials. Instead of people getting on the bandwagon for TWX development, let someone spearhead a TWX documentation project, and make me one of the editors (to weed out misinformation). That would do far more for TWX and those trying to learn scripting than additional developers.

+EP+


I 100% agree with that, would save the headache of allways asking/answering the same questions all the time. If it wasnt for people in the forum I would never have made the progress with TWX I did due to the lack of docs.

_________________
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."


Thu Jun 18, 2009 4:41 pm
Profile ICQ
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post Re: TWX 2.05 Beta
While working on a script tonight I realized one command that could clean up some scripts. A format for numbers that places the commas in the correct position. This would eliminate writing the insert procedure and also the kludge on how we have to swap values.

Currently it goes something like:

setVar $formatString $numberValue
gosub :formatNum
setVar $numberValueFormatted $formatString
...
...

echo $numberValueFormatted
echo $nextNumberFormat

:formatNum
....
return

A clean way of doing it would be something like: formatNumber $numberFormat $numberValue
where $numberValue (30000) is formatted to (30,000).

If there is a good way to to it now, I am open for suggestions. The above example on the current way I am doing it is pretty basic, but when you deal with 10 or more values to be formatted, it gets messy.

_________________
               / Promethius / Enigma / Wolfen /

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


Sat Jun 20, 2009 1:52 am
Profile ICQ
Commander

Joined: Sun Feb 25, 2001 3:00 am
Posts: 1838
Location: Guam USA
Unread post Re: TWX 2.05 Beta
Cant you just use

GetLengt and MergeText

I know it may get a little complicated , but you of all people
probly could pull this off with a few lines of code ;)

but as an added command , it might be nice to see number shown
with the commas if you like .... sometimes.

_________________
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


Sat Jun 20, 2009 2:59 am
Profile WWW
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post Re: TWX 2.05 Beta
I just striptext the commas out, and never bother to put them back in.

But yeh, u could just gettext in reverse, from length to 0, in 3 char increments.

Hehe. Maybe that should be the next coding challenge.

_________________
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


Sat Jun 20, 2009 4:09 am
Profile ICQ WWW
Commander
User avatar

Joined: Fri Jun 09, 2006 2:00 am
Posts: 1401
Location: Canada
Unread post Re: TWX 2.05 Beta
in just about every script I write:
Code:
setVar $CashAmount 1000000
Gosub :CommaSize

Echo "** DR. EVIL"
Echo "*"
Echo "* Gentlemen, it's come to my attention that a breakaway Russian Republic"
Echo "* called Kreplachistan will be transferring a nuclear warhead to the United"
Echo "* Nations in a few days. Here's the plan.  We get the warhead, and we hold "
Echo "* the world ransom..."
Echo "*                       (dramatic pause)"
Echo "*"
Echo "*                          ...FOR $" & $CashAmount & " DOLLARS!"
Echo "*"
Halt

:CommaSize
   StripText $CashAmount ","
   if ($CashAmount < 1000)
      #do nothing
   elseif ($CashAmount < 1000000)
       getLength $CashAmount $len
      setVar $len ($len - 3)
      cutText $CashAmount $tmp 1 $len
      cutText $CashAMount $tmp1 ($len + 1) 999
      setVar $tmp $tmp & "," & $tmp1
      setVar $CashAmount $tmp
   elseif ($CashAmount <= 999999999)
      getLength $CashAmount $len
      setVar $len ($len - 6)
      cutText $CashAmount $tmp 1 $len
      setVar $tmp $tmp & ","
      cutText $CashAmount $tmp1 ($len + 1) 3
      setVar $tmp $tmp & $tmp1 & ","
      cutText $CashAmount $tmp1 ($len + 4) 999
      setVar $tmp $tmp & $tmp1
      setVar $CashAmount $tmp
   end
   return

_________________
----------------------------
-= QUANTUM Computing 101: 15 = 3 x 5 ... 48% of the time.


Sat Jun 20, 2009 5:50 am
Profile ICQ YIM
Commander

Joined: Sun Feb 25, 2001 3:00 am
Posts: 1838
Location: Guam USA
Unread post Re: TWX 2.05 Beta
Great Job LS ;)

_________________
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


Sat Jun 20, 2009 10:15 am
Profile WWW
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post Re: TWX 2.05 Beta
LoneStar wrote:
in just about every script I write:
Code:
setVar $CashAmount 1000000
Gosub :CommaSize

Echo "** DR. EVIL"
Echo "*"
Echo "* Gentlemen, it's come to my attention that a breakaway Russian Republic"
Echo "* called Kreplachistan will be transferring a nuclear warhead to the United"
Echo "* Nations in a few days. Here's the plan.  We get the warhead, and we hold "
Echo "* the world ransom..."
Echo "*                       (dramatic pause)"
Echo "*"
Echo "*                          ...FOR $" & $CashAmount & " DOLLARS!"
Echo "*"
Halt

:CommaSize
   StripText $CashAmount ","
   if ($CashAmount < 1000)
      #do nothing
   elseif ($CashAmount < 1000000)
       getLength $CashAmount $len
      setVar $len ($len - 3)
      cutText $CashAmount $tmp 1 $len
      cutText $CashAMount $tmp1 ($len + 1) 999
      setVar $tmp $tmp & "," & $tmp1
      setVar $CashAmount $tmp
   elseif ($CashAmount <= 999999999)
      getLength $CashAmount $len
      setVar $len ($len - 6)
      cutText $CashAmount $tmp 1 $len
      setVar $tmp $tmp & ","
      cutText $CashAmount $tmp1 ($len + 1) 3
      setVar $tmp $tmp & $tmp1 & ","
      cutText $CashAmount $tmp1 ($len + 4) 999
      setVar $tmp $tmp & $tmp1
      setVar $CashAmount $tmp
   end
   return


k, now add 10 more vars that have to be formatted correctly with the output and you will see what I am talking about in regard to a mess.

The generic format I use works well, but I still have to do the setVar to a temp Var, gosub to format, set original to new formatted value and repeat for the next Var.

_________________
               / Promethius / Enigma / Wolfen /

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


Sat Jun 20, 2009 11:42 am
Profile ICQ
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post Re: TWX 2.05 Beta
This is the generic format I use for numbers:

Code:
# setup some test data
setVar $data "9 10 123 1234 12345 123456 1234567 12345679 123456789 1234567890 abracadabra 1234567899876543210"
getword $data $inputVar 1
setVar $i 2
while ($inputVar <> 0)
       gosub :genFormat
      echo ANSI_12 "*Input Var: " ANSI_11 $inputVar ANSI_12 "  Output Var: " ANSI_14 $outPutVar
      getword $data $inputVar $i
      add $i 1
end
halt

# now actually format it

:genFormat
  setVar $outputVar ""
  getLength $inputVar $cutLen
  while ($cutLen > 3)
      cutText $inputVar $tmpVar ($cutLen - 2) 3
      setVar $outPutVar  "," & $tmpVar & $outputVar
      subtract $cutLen 3
  end
  cutText $inputVar  $tmpVar 1 $cutLen
  setVar $outputVar $tmpVar & $outputVar
  return


Output:
Input Var: 9  Output Var: 9
Input Var: 10 Output Var: 10
Input Var: 123 Output Var: 123
Input Var: 1234 Output Var: 1,234
Input Var: 12345 Output Var: 12,345
Input Var: 123456 Output Var: 123,456
Input Var: 1234567 Output Var: 1,234,567
Input Var: 12345678 Output Var: 12,345,678
Input Var: 123456789 Output Var: 123,456,789
Input Var: 1234567890 Output Var: 1,234,567,890
Input Var: abracadabra Output Var: ab,rac,ada,bra
Input Var: 1234567899876543210 Output Var: 1,234,567,899,876,543,210


Yeah, I should have formatted a right pad on the $inputVar to make it in pretty columns. ;)

_________________
               / Promethius / Enigma / Wolfen /

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


Sat Jun 20, 2009 12:43 pm
Profile ICQ
Commander
User avatar

Joined: Fri Jun 09, 2006 2:00 am
Posts: 1401
Location: Canada
Unread post Re: TWX 2.05 Beta
Promethius wrote:
k, now add 10 more vars that have to be formatted correctly with the output and you will see what I am talking about in regard to a mess.

The generic format I use works well, but I still have to do the setVar to a temp Var, gosub to format, set original to new formatted value and repeat for the next Var.


You got me... dead-bang. Actually, I think you're suffering from a bit of tunnel vision. I mean, my little routine is not meant for

Code:
setvar $idx 1
while ($idx <= $arraysize)
   setVar $CashAmount $array[$idx]
   Gosub :CommaSize
   #sorry no pretty colours today  :)
   Echo "*Before: " & $array[$idx] & ", and After:" & $CashAmount
   add $idx 1
end


Not seeing the mess. But then again this is how every function-call is made(?) The Working parameter is either 'Destructive' or it isn't. Adding the comma's is for display purposes anyways.. if you want to perform some numeric function on the variable latter on.. you'd have to make sure you use the StripTExt Command and remove "," again because TWXProxy doesn't know how to perform math on:

"1" + "1,000" ='s "Script Terminated '1,000' is not a decimal number"

Promethius wrote:
Input Var: abracadabra Output Var: ab,rac,ada,bra
Input Var: 1234567899876543210 Output Var: 1,234,567,899,876,543,210

what is that anways: 1.2 Quintillion-Trillion-Zillion-Billion? I've can't even count that high..

_________________
----------------------------
-= QUANTUM Computing 101: 15 = 3 x 5 ... 48% of the time.


Sat Jun 20, 2009 3:27 pm
Profile ICQ YIM
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post Re: TWX 2.05 Beta
LS, I should have identified a bit more of what I am doing with the formatting. Basically it is to output into a TWX window, and/or a text file in an easier (for me anyway) format to read. The numeric vars are usually left alone so I don't end up with a crash.

The "mess" as I call it comes from:

setVar $inputVar $credits
gosub :genFormat
setVar $creditsDisp $outPutVar

setVar $inputVar $citTreasury
gosub :getFormat
setVar $citTreasuryDisp $outPutVar

... and this continues until everything is formatted and then output ...

I think I could clean up this part a little by simply creating a var such as $display and adding the text as I go instead of a seperate var, but I still end up with goSubs i.e.,

setVar $inputVar $credits
gosub :genFormat
setVar $display "*Credits: " & $outputVar

setVar $inputVar $citXfer
gosub :getFormat
setVar $display $display & " Cit Xfer: " & $outputVar "*"
....
setWindowContents xyz $display
write GAMENAME & "info.txt" $display

If there was a number formatting command within TWX, then the goSubs would be eliminated. A couple of others might be lPad and rPad to pad a string either left or right. Easy to write but still have the goSubs.

.. and I can't even begin to tell you what that last number is in my earlier example's output. ;)

_________________
               / Promethius / Enigma / Wolfen /

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


Sat Jun 20, 2009 8:01 pm
Profile ICQ
Ambassador
User avatar

Joined: Wed Nov 12, 2008 8:57 am
Posts: 3554
Location: Long Beach, CA
Unread post Re: TWX 2.05 Beta
ElderProphet wrote:
There has not been written a simpler scripting language to automate TradeWars play. If you'd like, I'd be happy to tell you the 20 most important TWX commands to learn, and that alone would give you the ability to write some basic scripts.

+EP+


I would love to know the 20 most important TWX commands.

Helix

_________________
Helix
Do I really look like a guy with a plan? You know what I am? I'm a dog chasing cars.
Lest we forget
I had to ask myself WWSGD?


Sat Jun 20, 2009 9:19 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 71 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

Who is online

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