View unanswered posts | View active topics It is currently Thu Sep 24, 2020 10:50 pm



Reply to topic  [ 14 posts ] 
 TWX Proxy - Asignment Operators 
Author Message
Ambassador
User avatar

Joined: Wed Apr 20, 2011 1:19 pm
Posts: 2433
Location: Oklahoma City, OK 73170 US
Unread post TWX Proxy - Asignment Operators
ok, since no one requested anything, I worked on one of my own requests:

TWX doesn't have an assignment operator, well is has:

Code:
setvar $puke true


... but wouldn't it be nice if you could use ":=" instead?

Code:
$puke := false


ok, I still want to put a ; at the end of that, but isn't that a lot easier to read?

and wouldn't it be nice if you could use "*=", "/=", "+=", "-=", "++", and "--" operators like this:

Code:
$dogs := 11

While $birds < 5
  $birds++
  $mice += 2 * $birds
  $dogs -= 2

  echo "Your cats ate " $birds " birds and " $mice " mice, and chased " $dogs " dogs*"
end

$dogs := 5
$cats := 1

while $dogs > 0
  $feline := $cats * 100
  $feline /= $cats + $dogs

  echo "You Have " $dogs " Dogs and " $cats " Cats, which is " $feline "% feline*"

  $Dogs--
  $cats *= 2
end


Well, i just finished writing this feature, and here is the output of the above script:

Code:
Your cats ate 1 birds and 2 mice, and chased 9 dogs
Your cats ate 2 birds and 6 mice, and chased 7 dogs
Your cats ate 3 birds and 12 mice, and chased 5 dogs
Your cats ate 4 birds and 20 mice, and chased 3 dogs
Your cats ate 5 birds and 30 mice, and chased 1 dogs
You Have 5 Dogs and 1 Cats, which is 16% feline
You Have 4 Dogs and 2 Cats, which is 33% feline
You Have 3 Dogs and 4 Cats, which is 57% feline
You Have 2 Dogs and 8 Cats, which is 80% feline
You Have 1 Dogs and 16 Cats, which is 94% feline


I think I managed to get all 7 new mathematical operators in there, and used a few of the old operators that most people forget were added in TWX 2.0. It is just a bit of compiler fakery, as it is still using setvar, add, multiple, etc... internally... but I think it is so much easier to read when using assignment operators instead of functions. don't you?

_________________
Regards,
Micro

Website: http://www.microblaster.net
TWGS2.20b/TW3.34: telnet://twgs.microblaster.net:2002

ICQ is Dead Jim! Join us on Discord:
https://discord.gg/frrjg6r


Mon Dec 30, 2019 2:21 pm
Profile ICQ YIM WWW
Lieutenant J.G.

Joined: Mon Dec 01, 2014 5:39 pm
Posts: 412
Unread post Re: TWX Proxy - Asignment Operators
Very nice Micro, I think I eluded to wanting something like this months (years?) ago.

I may get back into the game at some point and will surely appreciate your efforts.


Thu Jan 09, 2020 6:49 am
Profile
Ambassador
User avatar

Joined: Fri Feb 23, 2001 3:00 am
Posts: 3973
Location: USA
Unread post Re: TWX Proxy - Asignment Operators
Missing Modulus %

But, I don't know if the % symbol is recognizable for TWXProxy and have been thinking of when it may be applicable to a script.

Just something I ponder.

_________________

BOTE 1998 Champs: Team Fament
HHT 2015 Champs: Cloud09
Big Game 2016 Champs: Draft team
HHT 2018 Champs: Rock Stars
Big Game 2019 Champs: Draft Team


Classic Style Games Here:
telnet://Cruncherstw.no-ip.biz:2002

Web page from 1990's: https://web.archive.org/web/20170103155645/http://tradewars.fament.com/Cruncher/tradewar.htm
Blog with current server info: http://cruncherstw.blogspot.com
Discord: https://discord.gg/4dja5Z8
E-mail: Cruncherstw@gmail.com
FaceBook: http://www.facebook.com/CrunchersTW


Thu Jan 09, 2020 8:23 am
Profile ICQ WWW
Ambassador
User avatar

Joined: Wed Apr 20, 2011 1:19 pm
Posts: 2433
Location: Oklahoma City, OK 73170 US
Unread post Re: TWX Proxy - Asignment Operators
It is not the only operator missing:

Image

Modulus is the remainder of a division operation.

10 / 4 = 2.5
10 % 4 = 5

Sounds like something an accountant would use. :)

I might add it as it is the only "Arithmetic" operator missing.
Maybe it would come in handy in a haggling routine?

_________________
Regards,
Micro

Website: http://www.microblaster.net
TWGS2.20b/TW3.34: telnet://twgs.microblaster.net:2002

ICQ is Dead Jim! Join us on Discord:
https://discord.gg/frrjg6r


Thu Jan 09, 2020 12:21 pm
Profile ICQ YIM WWW
Ambassador
User avatar

Joined: Fri Feb 23, 2001 3:00 am
Posts: 3973
Location: USA
Unread post Re: TWX Proxy - Asignment Operators
Micro wrote:
It is not the only operator missing:

Modulus is the remainder of a division operation.

10 / 4 = 2.5
10 % 4 = 5

Sounds like something an accountant would use. :)

I might add it as it is the only "Arithmetic" operator missing.
Maybe it would come in handy in a haggling routine?


No, I actually learned about that when I went back to learn programming.

Maybe EP could use it for his haggle?

_________________

BOTE 1998 Champs: Team Fament
HHT 2015 Champs: Cloud09
Big Game 2016 Champs: Draft team
HHT 2018 Champs: Rock Stars
Big Game 2019 Champs: Draft Team


Classic Style Games Here:
telnet://Cruncherstw.no-ip.biz:2002

Web page from 1990's: https://web.archive.org/web/20170103155645/http://tradewars.fament.com/Cruncher/tradewar.htm
Blog with current server info: http://cruncherstw.blogspot.com
Discord: https://discord.gg/4dja5Z8
E-mail: Cruncherstw@gmail.com
FaceBook: http://www.facebook.com/CrunchersTW


Thu Jan 09, 2020 6:07 pm
Profile ICQ WWW
Ambassador
User avatar

Joined: Wed Apr 20, 2011 1:19 pm
Posts: 2433
Location: Oklahoma City, OK 73170 US
Unread post Re: TWX Proxy - Asignment Operators
Cruncher wrote:
Maybe EP could use it for his haggle?

I know he uses floating point math in EP haggle, so I am not sure.

_________________
Regards,
Micro

Website: http://www.microblaster.net
TWGS2.20b/TW3.34: telnet://twgs.microblaster.net:2002

ICQ is Dead Jim! Join us on Discord:
https://discord.gg/frrjg6r


Thu Jan 09, 2020 7:07 pm
Profile ICQ YIM WWW
Lieutenant J.G.

Joined: Mon Dec 01, 2014 5:39 pm
Posts: 412
Unread post Re: TWX Proxy - Asignment Operators
Micro wrote:
Cruncher wrote:
Maybe EP could use it for his haggle?

I know he uses floating point math in EP haggle, so I am not sure.


If this is some tricky way to expose how his haggling routine actually works.. then well played!


Thu Jan 09, 2020 7:19 pm
Profile
Ambassador
User avatar

Joined: Wed Apr 20, 2011 1:19 pm
Posts: 2433
Location: Oklahoma City, OK 73170 US
Unread post Re: TWX Proxy - Asignment Operators
Hammer_2 wrote:
If this is some tricky way to expose how his haggling routine actually works.. then well played!

No I haven't looked at the code.

_________________
Regards,
Micro

Website: http://www.microblaster.net
TWGS2.20b/TW3.34: telnet://twgs.microblaster.net:2002

ICQ is Dead Jim! Join us on Discord:
https://discord.gg/frrjg6r


Thu Jan 09, 2020 8:41 pm
Profile ICQ YIM WWW
Ambassador
User avatar

Joined: Fri Feb 23, 2001 3:00 am
Posts: 3973
Location: USA
Unread post Re: TWX Proxy - Asignment Operators
Micro wrote:
Hammer_2 wrote:
If this is some tricky way to expose how his haggling routine actually works.. then well played!

No I haven't looked at the code.


Well... it floats the wrong way sometimes, maybe he does need Modulus :)

_________________

BOTE 1998 Champs: Team Fament
HHT 2015 Champs: Cloud09
Big Game 2016 Champs: Draft team
HHT 2018 Champs: Rock Stars
Big Game 2019 Champs: Draft Team


Classic Style Games Here:
telnet://Cruncherstw.no-ip.biz:2002

Web page from 1990's: https://web.archive.org/web/20170103155645/http://tradewars.fament.com/Cruncher/tradewar.htm
Blog with current server info: http://cruncherstw.blogspot.com
Discord: https://discord.gg/4dja5Z8
E-mail: Cruncherstw@gmail.com
FaceBook: http://www.facebook.com/CrunchersTW


Thu Jan 09, 2020 11:17 pm
Profile ICQ WWW
Lieutenant
User avatar

Joined: Tue Dec 17, 2002 3:00 am
Posts: 504
Location: Virginia
Unread post Re: TWX Proxy - Asignment Operators
Hammer_2 wrote:
Micro wrote:
Cruncher wrote:
Maybe EP could use it for his haggle?

I know he uses floating point math in EP haggle, so I am not sure.


If this is some tricky way to expose how his haggling routine actually works.. then well played!


Pretty much everyone knows how it works now. The source code is out there.

_________________
TOURNAMENT WINNER: ICE 2017 - ICE 2019 - SUMMER SPLASH 2019 - XMAS TOURNEY 2019


Fri Jan 10, 2020 11:24 am
Profile ICQ
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1122
Location: Augusta, GA
Unread post Re: TWX Proxy - Asignment Operators
Nice work Micro!

+EP+

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


Mon Jan 13, 2020 7:55 pm
Profile WWW
Ambassador
User avatar

Joined: Wed Apr 20, 2011 1:19 pm
Posts: 2433
Location: Oklahoma City, OK 73170 US
Unread post Re: TWX Proxy - Asignment Operators
ElderProphet wrote:
Nice work Micro!

+EP+

Thanks, That means a lot coming from you!

_________________
Regards,
Micro

Website: http://www.microblaster.net
TWGS2.20b/TW3.34: telnet://twgs.microblaster.net:2002

ICQ is Dead Jim! Join us on Discord:
https://discord.gg/frrjg6r


Tue Jan 14, 2020 12:15 pm
Profile ICQ YIM WWW
Ambassador
User avatar

Joined: Wed Apr 20, 2011 1:19 pm
Posts: 2433
Location: Oklahoma City, OK 73170 US
Unread post Re: TWX Proxy - Asignment Operators
Cruncher wrote:
Missing Modulus %.

I added the modulus command and operator, and I already found a use for it when writing the new performance timer commands:

Code:
StartTimer $Timer1

# Do something that may take a while

StopTimer $Timer1

$Seconds := $Timer1 / 1000
$MiliSec := $Timer1 % 1000

Echo "You command took " $Seconds " seconds and " $MiliSec " ms to complete."



In this example "$Timer1 % 1000" returns the number of ms elpased.

_________________
Regards,
Micro

Website: http://www.microblaster.net
TWGS2.20b/TW3.34: telnet://twgs.microblaster.net:2002

ICQ is Dead Jim! Join us on Discord:
https://discord.gg/frrjg6r


Wed Jul 01, 2020 11:04 am
Profile ICQ YIM WWW
Ambassador
User avatar

Joined: Fri Feb 23, 2001 3:00 am
Posts: 3973
Location: USA
Unread post Re: TWX Proxy - Asignment Operators
Micro wrote:
Cruncher wrote:
Missing Modulus %.

I added the modulus command and operator, and I already found a use for it when writing the new performance timer commands:

Code:
StartTimer $Timer1

# Do something that may take a while

StopTimer $Timer1

$Seconds := $Timer1 / 1000
$MiliSec := $Timer1 % 1000

Echo "You command took " $Seconds " seconds and " $MiliSec " ms to complete."



In this example "$Timer1 % 1000" returns the number of ms elpased.


Nice!

_________________

BOTE 1998 Champs: Team Fament
HHT 2015 Champs: Cloud09
Big Game 2016 Champs: Draft team
HHT 2018 Champs: Rock Stars
Big Game 2019 Champs: Draft Team


Classic Style Games Here:
telnet://Cruncherstw.no-ip.biz:2002

Web page from 1990's: https://web.archive.org/web/20170103155645/http://tradewars.fament.com/Cruncher/tradewar.htm
Blog with current server info: http://cruncherstw.blogspot.com
Discord: https://discord.gg/4dja5Z8
E-mail: Cruncherstw@gmail.com
FaceBook: http://www.facebook.com/CrunchersTW


Wed Jul 01, 2020 11:40 am
Profile ICQ WWW
Display posts from previous:  Sort by  
Reply to topic   [ 14 posts ] 

Who is online

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