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