Our First Script!
Wee Beginnings
Ok! Now let's write a simple script for walking back and forth. To do so, open up Scite, then save it in the Scripts folder of your PokeBot directory. This will ensure that your script will be compliant with PokeBot Standards.
Now, for the first line of code, type in pokebot_init(). This function should be called at the beginning of each script, as it sets up the basic mechanisms of PokeBot. Notice how the function ends with closed parenthesis (). This means that there are no arguments to the script-- you'll see what I mean in just a little bit.
Now, skip down a line or two and type in the following...
WALK:
return
Subroutines
You've just created a subroutine! Subroutines are executed when called upon. The name of this subroutine is "WALK". Note the colon afterwards-- this indicates the beginning of the subroutine. The return on the other hand, indicates then end. You must always have a return after a subroutine-- otherwise things will turn out ugly.
Let's Take a Walk
Ok, so we have our subroutine down. Now, between WALK: and return, type in the following:
Loop
{
walk_right(1)
walk_left(1)
}
So, now our entire script should look like this:
pokebot_init()
Loop
{
walk_right(1)
walk_left(1)
}
Return
The three lines we just added to the script serves two purposes
The functions walk_right() and walk_left() both must have arguments... hence the "1" between the parenthesis. In this case, the 1 tells the script to walk in a direction for one tile. So basically, the script tells the player to walk right one tile, then walk left one tile. The words Loop causes the walking to loop for an infinite number of times. Writing Loop, 2 instead of Loop causes the walking sequence to loop twice.
Wrapping Up
Looks like we're done with the script! Press F5 to see your script in action, or press the small blue play icon on the Scite user interface. If you would like, you can compile the script into an actual EXE file with ahk2exe. It comes with AutoHotKey, and it can be found in the directory where you installed AHK.
Well that wasn't too bad! You've created a basic script for walking back and forth! Now head over to documentation to explore what else the PokeBot library offers! Or, you can take a look at ideas for distributing your scripts!
Ok! Now let's write a simple script for walking back and forth. To do so, open up Scite, then save it in the Scripts folder of your PokeBot directory. This will ensure that your script will be compliant with PokeBot Standards.
Now, for the first line of code, type in pokebot_init(). This function should be called at the beginning of each script, as it sets up the basic mechanisms of PokeBot. Notice how the function ends with closed parenthesis (). This means that there are no arguments to the script-- you'll see what I mean in just a little bit.
Now, skip down a line or two and type in the following...
WALK:
return
Subroutines
You've just created a subroutine! Subroutines are executed when called upon. The name of this subroutine is "WALK". Note the colon afterwards-- this indicates the beginning of the subroutine. The return on the other hand, indicates then end. You must always have a return after a subroutine-- otherwise things will turn out ugly.
Let's Take a Walk
Ok, so we have our subroutine down. Now, between WALK: and return, type in the following:
Loop
{
walk_right(1)
walk_left(1)
}
So, now our entire script should look like this:
pokebot_init()
Loop
{
walk_right(1)
walk_left(1)
}
Return
The three lines we just added to the script serves two purposes
- It actually does the walking
- It makes sure that the script loops.
The functions walk_right() and walk_left() both must have arguments... hence the "1" between the parenthesis. In this case, the 1 tells the script to walk in a direction for one tile. So basically, the script tells the player to walk right one tile, then walk left one tile. The words Loop causes the walking to loop for an infinite number of times. Writing Loop, 2 instead of Loop causes the walking sequence to loop twice.
Wrapping Up
Looks like we're done with the script! Press F5 to see your script in action, or press the small blue play icon on the Scite user interface. If you would like, you can compile the script into an actual EXE file with ahk2exe. It comes with AutoHotKey, and it can be found in the directory where you installed AHK.
Well that wasn't too bad! You've created a basic script for walking back and forth! Now head over to documentation to explore what else the PokeBot library offers! Or, you can take a look at ideas for distributing your scripts!