www.ClassicTW.com
http://www.classictw.com/

Basic Scripting Doc
http://www.classictw.com/viewtopic.php?f=15&t=21677
Page 1 of 1

Author:  Promethius [ Sun Mar 15, 2009 10:56 pm ]
Post subject:  Basic Scripting Doc

The document below is for basic scripting in TWX. It was created using OpenOffice and saved as MS-Word compatible.

It shows some ideas on scripting, but by no means the only way to do something. It could have bad habits also in the examples, but it should give people a basic starting point. If you find errors, let me know. If it helps you write a script that pods me, so much the better.

Attachments:
File comment: Basic scripting
twxScripting.doc [142.5 KiB]
Downloaded 588 times

Author:  Promethius [ Tue Mar 17, 2009 9:45 pm ]
Post subject:  Re: Basic Scripting Doc

Looks like the document has been downloaded a few times. I need to find out if it is of any help, and what could be improved before I try putting together part 2 - and what should be included in part 2. I've never written any documentation type material for a computer scripting language and really don't know how far off base I am in the writing style.

Author:  mob [ Tue Mar 17, 2009 9:53 pm ]
Post subject:  Re: Basic Scripting Doc

ok...

1. Nicely written, even for a noob scriptor.
2. Touched on some decent points and not just "basic" things.
3. It turns into an actual product that someone could use and test/edit to their liking.

It was very cool prom, I always get excited when you put something new out whether its a script or now your docs. Recently Ive noticed TWX scripting has been sort of a circle of people with some tricks/knowledge its cool to get some of this info out!

Thanks again killa!!

Author:  ElderProphet [ Wed Mar 18, 2009 12:44 am ]
Post subject:  Re: Basic Scripting Doc

In general, we in the inner circle, as you say, fall all over ourselves trying to answer questions and give examples. There is no shortage of willingness to help, but there is indeed a shortage of basic instruction and structured learning. Stand-alone docs like this are helpful.

Regarding the doc, I have 2 points Prom.
1. You mention that my script editor, TWXIDE, might be worth a look. This tells me that you yourself haven't really given it a go. Shame on you. Try it and tell me it sux, but don't not try it for crying out loud.

2. You show a classic example of reading a text file into an array, line by line. I think it is useful to see as an example. You should follow it up with the dramatically faster readToArray command, which does the same thing in 1 line.

Hopefully you find point 2 constructive anyway ;)

Regards,
+EP+

Author:  mob [ Wed Mar 18, 2009 6:53 am ]
Post subject:  Re: Basic Scripting Doc

ElderProphet wrote:
In general, we in the inner circle, as you say, fall all over ourselves trying to answer questions and give examples. There is no shortage of willingness to help, but there is indeed a shortage of basic instruction and structured learning. Stand-alone docs like this are helpful.


When TWX was released and people picked up TWX scripting there were a handful of veterans that took it on and it was at its height then. Now most of the scripts used today by some are either written by those veterans or by people who were kinda schooled along the way with them. There should be more players interested in this because thats how new scripts and new idea's become real.

I really usrge new players to take on some small tasks with TWX scripting and make little things here and there with docs like this or the knowledge on Sings mirror of cabal. Thanks prom, and thanks ep for all your support to us trying to learn a couple things.

Author:  Kaus [ Wed Mar 18, 2009 9:31 am ]
Post subject:  Re: Basic Scripting Doc

Promethius wrote:
The document below is for basic scripting in TWX. It was created using OpenOffice and saved as MS-Word compatible.

It shows some ideas on scripting, but by no means the only way to do something. It could have bad habits also in the examples, but it should give people a basic starting point. If you find errors, let me know. If it helps you write a script that pods me, so much the better.


I liked it Prom and have added it as one of my referances, It is very well written and wish I had it about 4-5 months ago when i was struggling with some key concepts. The twx window command was of some particular interest to me as I have not had a chance to play around with it. In part two if you feel so inclined a scroll back window example would be neat :)

* Off topic of the tutorial, TwXide rocks has some stuff that I hope EP address's in his next realease but the modularity of the program and size alone make it a great asset to any scripters repository.
* I think the issue with scripting is allot (read: not all) of people are lazy when it comes to scripting (myself included at times). In that if it doesnt allready exist wait till it does. Public scripting can be a pretty thankless job and there are plenty of people that love to tear down scripts(often people who dont script). In my experiance there are even more people who don't want/don't have the time/don't care to learn even the basics for various reasons. So I guess it all comes full circle in that if its not easy it's not worth doing.*

I look forward to your next installment prom, if the gods of this forum (Mod's) see fit maybe it will get stickied so we don't lose the thread into the abyss.

Author:  Thrawn [ Wed Mar 18, 2009 10:57 am ]
Post subject:  Re: Basic Scripting Doc

I found it very useful, and after receiving your permission, have added it to the TradeWars Academy application project I am working on. Let me know when your part 2 is done and I'd be happy to add it as well.

Author:  Traitor [ Wed Mar 18, 2009 11:44 am ]
Post subject:  Re: Basic Scripting Doc

Ok, I'll bite.

TWX Scripts .TS vs .CTS
.cts scripts load faster, since they are already compiled. .ts scripts have to be compiled on the fly. It doesn't matter 99% of the time. However, all of my combat scripts are pre-compiled. :mrgreen:

Arrays
"Arrays can be viewed as variables with a very distinct advantage, multiple setting of the variable (array) by using a looping structure such as while/end."

You might want to add some more fluff about what an array really is and how useful they are. http://www.tw-cabal.com/strategy/twxscripthelp.html goes into some detail on that. Prom, feel free to take what you need from that.

Using Script Triggers
I would move that up higher. Understanding triggers is, in my opinion, more important than understanding arrays. I would move it above the Let's Create Something or even the TWX Windows section.


Menus
You might want to add a section on menus too. Or just put a link in your doc to this one: http://www.tw-cabal.com/strategy/twxscripthelp2.html Menus are evil and tedious, but any complex script will benefit from properly coded menus.

As to your code, it looks ok. However, I didn't look at it very closely.

Author:  Promethius [ Wed Mar 18, 2009 7:49 pm ]
Post subject:  Re: Basic Scripting Doc

Traitor wrote:
Ok, I'll bite.

TWX Scripts .TS vs .CTS
.cts scripts load faster, since they are already compiled. .ts scripts have to be compiled on the fly. It doesn't matter 99% of the time. However, all of my combat scripts are pre-compiled. :mrgreen:

Arrays
"Arrays can be viewed as variables with a very distinct advantage, multiple setting of the variable (array) by using a looping structure such as while/end."

You might want to add some more fluff about what an array really is and how useful they are. http://www.tw-cabal.com/strategy/twxscripthelp.html goes into some detail on that. Prom, feel free to take what you need from that.

Using Script Triggers
I would move that up higher. Understanding triggers is, in my opinion, more important than understanding arrays. I would move it above the Let's Create Something or even the TWX Windows section.


Menus
You might want to add a section on menus too. Or just put a link in your doc to this one: http://www.tw-cabal.com/strategy/twxscripthelp2.html Menus are evil and tedious, but any complex script will benefit from properly coded menus.

As to your code, it looks ok. However, I didn't look at it very closely.


I agree with what you are saying and I made an assumption (which I tell people not to do when scripting) on the .cts and .ts script comparison. There is a delay on the .ts compile, but the execution speed once compiled is the same. The delay, no matter how small, can get one killed because it can give the opponent a split second advantage.

I believe a menus section for part 2 would be a very good idea and I think providing a link to your example probably the most effective. I really don't want to reinvent the wheel on material that is already out and done very well.

Part 2 will cover some additional information on arrays and hopefully give some food for thought to people.

Ideally any tutorial should go through a peer review process of some type to insure accuracy.

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