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

Scripting help
https://mail.black-squirrel.com/viewtopic.php?f=15&t=13146
Page 1 of 2

Author:  Zoso [ Mon Jun 13, 2005 3:44 pm ]
Post subject: 

Plugging away at some code here and have run into a bit of a wall(Grimy's forum down). What is the longest tunnel you have encountered? I cring when I see...

SetArray $Tunnel SECTORS

Is there any internal maximum that TWGS sets for Tunnels?

Zoso
Thanx in advance

Author:  Harley Nuss [ Mon Jun 13, 2005 4:07 pm ]
Post subject: 

no

Author:  Zoso [ Mon Jun 13, 2005 5:02 pm ]
Post subject: 

Thanx for the quick response K3, anyone else care to comment any further?
quote:What is the longest tunnel you have encountered?

I suppose I ought to breakdown and grab myself a copy of TWGS so that I can test locally eh?

Zoso

Author:  Harley Nuss [ Mon Jun 13, 2005 9:41 pm ]
Post subject: 

I remember at least one 12 sector tunnel in a game. Don't remember anything larger than that right off hand.

Author:  Traitor [ Mon Jun 13, 2005 10:10 pm ]
Post subject: 

I haven't seen one more than 12 long either in a normal bang, even in 20k games.

As far as I know, there is no limit, you could get one 500 sectors long I suppose. And the sysop could always MAKE one that long too.

Author:  Zoso [ Mon Jun 13, 2005 11:56 pm ]
Post subject: 

Kewl, I too haven't seen one more than 10 in length. Most of that size I have seen are generally comprimised anywas. I guess it's not a big deal to leave the array to univerese size. Just being picky I guess.

Zoso

Author:  ElderProphet [ Tue Jun 14, 2005 1:31 am ]
Post subject: 

I generally opt for dynamic arrays if I'm going to be looking at the variable dump in TWX. Keep in mind that you can zero an array after it has been created so you don't have to look at a 20,000 line variable dump of a static array. Use this syntax:
setArray $tunnels 0

Creating a dynamic array is faster than creating a large static array, so if you are just going to be working with an array of ~10 indexes, the speed of the static array will be moot.

+EP+

Author:  Zoso [ Tue Jun 14, 2005 9:48 am ]
Post subject: 

quote:setArray $tunnels 0

Just so I understand completly, The above Array will accept any amount of indexes, whether it be 1 or 1000.
Staying on the same topic, deos TWX support multi-dimensional arrays? (Dynamic/Static or both?) And is it limited?

SetArray $Tunnels 0,0

Zoso

Author:  ElderProphet [ Tue Jun 14, 2005 10:53 am ]
Post subject: 

To recap, the syntax I used above is as follows:
setArray $tunnels 0

This command will clear any existing array named $tunnels, and create a new, unpopulated dynamic array. A dynamic array will accept any amount of indexes, and they need not be numbers as with a static array.

TWX does support multidimensional arrays. You'll usually declare each dimension of a static array at the beginning, as follows:
setArray $data 5000 20

That will create an array named $data with 5000 indexes, and each of those 5000 indexes will have 20 sub-indexes. I *think* the number of dimensions is limited to 256, or available memory... whichever occurs first. If you can understand how to make efficient use of > 256 dimensions, then you should be curing cancer, not playing TW![:P]

You can declare a dimension at any time, and you can even combine static and dynamic dimensions. So if you have a dynamic array $tunnels, and you find a new tunnel 11 sectors in size, you can create a static dimension in your dynamic array $tunnels, as follows:
setArray $tunnels[$tunnelCount] 11

A tutorial for Arrays in TWX is long overdue. Bug me enough and I'll write one.[;)] Until then, I hope this has been helpful.

+EP+

Author:  Zoso [ Tue Jun 14, 2005 11:31 am ]
Post subject: 

EP, Once again you surpassed what I had expected for an answer. Thanks for the great recap on arrays, and yes please write a tutorial, that is... when your done with all of your other projects [:D]

Zoso

Author:  Traitor [ Tue Jun 14, 2005 12:12 pm ]
Post subject: 

quote:Originally posted by ElderProphet

A tutorial for Arrays in TWX is long overdue. Bug me enough and I'll write one.[;)] Until then, I hope this has been helpful.

+EP+

Agreed. While this:
http://www.tw-cabal.com/strategy/twxscripthelp.html
Gives a pretty good description of an array, and a few examples of where to use them, it's still lacking. Well, that and the scripts are garbage compared to what I write now.

So, EP, after the next beta haggle, and after the next release of TWX Proxy, and after we iron out those other experiments... [:D], how about taking a crack at a revision of the above?

Author:  ElderProphet [ Tue Jun 14, 2005 6:40 pm ]
Post subject: 

Sorry Traitor... I didn't mean to say that in an insulting way.

Zoso, it's always a pleasure to help.

I actually wrote a tutorial once for TWXProxy.com, but lost it in a harddrive crash about a year ago. I'll see what I can come up with in the next few weeks. I think it would sure save people a lot of time. For most people who lack a computer science degree, arrays can be a tough concept. And even efficient TWX scripters probably don't use them in their full capacity.

+EP+

Author:  Traitor [ Wed Jun 15, 2005 4:17 am ]
Post subject: 

heh. didn't take it that way at all. I knew what you meant

Author:  Zoso [ Wed Jun 15, 2005 10:18 am ]
Post subject: 

quote:I think it would sure save people a lot of time. For most people who lack a computer science degree, arrays can be a tough concept. And even efficient TWX scripters probably don't use them in their full capacity.

Nod, it took me quite some time to get my head around the concept of arrays. However, know that I've been fooling with them for a number of weeks I've begun rewriting alot of stuff I had done in the past.
Note - I'm really digging these multi-dimensional arrays.

Zoso

Author:  Maniac [ Thu Jun 16, 2005 12:03 am ]
Post subject: 

Zoso
One suggestion that really helped me with arrays especially dimensions was to look at it like a single dimension array is just a list of items a matrix(2 dimensional array) is was like a piece of paper with rows and columns a 3 dimensional array is a stack of pieces of paper.... a 4th dimensional was a filing cabinete with stacks of paper, where each drawer holds a stack of paper you can go on forever if you can visualize it to something you can relate to.

But there is an old saying K.I.S.S which if you as a scripter/programmer which you in fact are because you are making a program respond to outside stimuli whether it be a keystroke/responsive from the server or even the completion of another script.

Xide deserves more credit than he's getting. I for one am awed at the way he has written TWXProxy (even if Delphi is not my strong point) and hereby nominate him for inclusion into the TradeWars Hall of Fame.

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