PDA

View Full Version : Preparing to write a script - What needs done first



Esteban
09-01-2010, 02:04 AM
Introduction

While I have been taking an Introduction to Programming class, I have found myself thinking back to my days as a scripter here at SRL. I always had a hard time getting myself to complete a script. Until now, I never knew what kept me from getting the script completed, or even started. After just a few days in my Programming class, I realized what my problem was: I wasn't prepared to write the script. I hadn't gathered all the information I needed to successfully write a complete script. In this tutorial, I will go over what information needs to be gathered in order to write a proper script.

Define the Problem

The first part in preparing to write a script is defining the problem. You may think that when I say defining the problem, I mean what I want the script to accomplish, but it is more than that. For every script, you need to identify the variables, the inputs, the calculations, and the outputs. All of these need to be known in order to start writing your script. Yes, you can identify all of these as you script, but you will waste time and only make it harder on yourself.

Define Inputs

Inputs are what users of your script will be entering into your script so that it has the proper information to know how to approach the problem. Your script may have multiple locations where it may work, different tasks that it can perform, or a certain goal that users are aiming for. You need to gather this information from the script user, usually via a form (much easier for people who aren't familiar with coding), or by having them directly enter the information into the script's code.

Define Outputs

Usually, your script won't be outputting a whole lot of information to the user. In this case, I mean the steps a script will follow to complete it's task. Let's look at an AutoFighter for example. In an AutoFighter, the script will probably walk to what is being fought, fight some monsters, eat to heal, pick up items, solve randoms, and perhaps go back to a bank to deposit items and withdraw more food. Knowing these steps the script will need to do will help you determine how the script will approach completing each step and what variables are needed for each step.

Determine Processing

The processing is how a script will go by accomplishing it task at hand. I do not mean actually writing the code to solve the current task, but to outline a general idea of how the script will solve it. For example, if you are walking a road, you will need to know the road colors, set the compass to a certain direction, and have the script click on the minimap to walk. Exactly how this will be done will be determined when you begin writing the script.

Define Variables

Variables are information information a script needs in order to solve the task at hand. Colors, text, coordinates, DTMs, mouse position, and so on are all variables needed by the script to solve its task. Identifying needed variable will help you getting ready to start writing your next script.

Conclusion

Knowing inputs, the processing, outputs, and variables before starting to write a script will save you a lot of time and headaches. Writing the script will be a much easier and smoother process. Knowing these before you begin writing a script may also help you identify varibles, inputs, etc that you may not have thought of if you were scripting on-the-go.

bugger0001
09-12-2010, 01:37 PM
I absolutely agree with this one. For example my first script, a Rimmington miner, which got me members, took a total of 2 months from me to complete it. I had a concept for it, but wasn't exactly aware of all the details I had to deal with and therefore writing the script was a real pain in the ***.

Then again the next script I wrote, a Fally smelter, which only needed about 8 hours to complete. And that was because I had figured out all the essential things such as what the script has to do, what methods will I be using, what kind of possible difficulties might I run into and so on.

Since then I have wrote a few private scripts that aren't too complicated, but still get everything that's needed done. Now if I think back to my first script, I must admit that lots of things could've been solved way easier than I did back then. That's why all the above mentioned points are crucial - you get things done far easier and quicker.

Esteban
09-14-2010, 09:50 PM
Too bad I hadn't released this tutorial before you started scripting. Perhaps I should have this moved into the Beginners section?