Tutorial 1 - The basics
Okay, lets start out with the basics.
In this tutorial we will learn how to define our CLEO scripts and make them readable by the game and also enable "Infinite run" for the player
Please NOTE: The only opcode what works in a MAIN but doesn't work in a CLEO script is:
Create_thread @label <-- I've never understood why this opcode crashes the CLEO script in which it sits but unfortunately you can only use it in a MAIN. However! Do not be disheartened because there are ways around this!:D
Right then, lets get started, Open up Sanny Builder.
You should see this screen (Click to enlarge):
In this tutorial we will learn how to define our CLEO scripts and make them readable by the game and also enable "Infinite run" for the player
Please NOTE: The only opcode what works in a MAIN but doesn't work in a CLEO script is:
Create_thread @label <-- I've never understood why this opcode crashes the CLEO script in which it sits but unfortunately you can only use it in a MAIN. However! Do not be disheartened because there are ways around this!:D
Right then, lets get started, Open up Sanny Builder.
You should see this screen (Click to enlarge):
If its your first time opening Sanny Builder you will need to edit some settings, View the video below and follow to correctly configure Sanny Builder
If you have been through this already just skip forward
Click here to view the video
Now you have configured Sanny Builder and created a new file you need to define your CLEO script as a CLEO script so the game can recognize it.
To do this type this code at the top of your newly created file:
If you have been through this already just skip forward
Click here to view the video
Now you have configured Sanny Builder and created a new file you need to define your CLEO script as a CLEO script so the game can recognize it.
To do this type this code at the top of your newly created file:
{$CLEO}
0000:
0000:
(Please note, the code will not show blue in Sanny Builder, I've just used this colour to define the code from normal text)
Now press F6 (Compiles your CLEO script to a selected directory) If you have never compiled a script before a dialog box pops up, Just select the CLEO folder in your games directory. If you don't select the CLEO folder inside your game directory then the game will not run your script
Okay, next we need to add some labels (Labels are like containers, They hold all your bits of code)
So, im going to add 2 (NOTE: You do not need to name your labels 1 and 2, you can choose the name):
Now press F6 (Compiles your CLEO script to a selected directory) If you have never compiled a script before a dialog box pops up, Just select the CLEO folder in your games directory. If you don't select the CLEO folder inside your game directory then the game will not run your script
Okay, next we need to add some labels (Labels are like containers, They hold all your bits of code)
So, im going to add 2 (NOTE: You do not need to name your labels 1 and 2, you can choose the name):
:1
:2
:2
Labels are wrote like this:
: <<-- Colon comes before your labelnamelabelname <<-- this can be anything
Like so:
:labelname
Now its time to add your code and make your script do something, fortunately for this tutorial all the opcode we will use are the same in all 3 games (3, VC and SA) however this will not be the case for other opcodes
So, inside the first label we need to check if the player is defined:
Key:
Blue text = Code
Black text = Information
(Only the blue code should be typed/copied into Sanny Builder. Unless you want the information as a reference)
: <<-- Colon comes before your labelnamelabelname <<-- this can be anything
Like so:
:labelname
Now its time to add your code and make your script do something, fortunately for this tutorial all the opcode we will use are the same in all 3 games (3, VC and SA) however this will not be the case for other opcodes
So, inside the first label we need to check if the player is defined:
Key:
Blue text = Code
Black text = Information
(Only the blue code should be typed/copied into Sanny Builder. Unless you want the information as a reference)
:1
wait 0 <-- is ALWAYS necessary in if checks to stop the game from crashing
if
0256: player $PLAYER_CHAR defined <-- Check if the player is defined
jf @1 <-- This is a "Jump if false" opcode and jumps if the above opcode returns false
wait 0 <-- is ALWAYS necessary in if checks to stop the game from crashing
if
0256: player $PLAYER_CHAR defined <-- Check if the player is defined
jf @1 <-- This is a "Jump if false" opcode and jumps if the above opcode returns false
If the "Player defined" opcode returns true then the code skips past the "Jump if false" opcode and carries on down the script, reaching the label "2:"
:2
0330: set_player $PLAYER_CHAR infinite_run 1 <-- This opcode sets the "Infinite run" Condition to true, You can only use 0 and 1, 1 being true, 0 being false
0330: set_player $PLAYER_CHAR infinite_run 1 <-- This opcode sets the "Infinite run" Condition to true, You can only use 0 and 1, 1 being true, 0 being false
In the "2:" label above there wasn't an "If" statement meaning we didn't have to put a wait in there.
The wait code can be used in all different kinds of ways and isn't just for "If" checks, keep this in mind.
Now the full code looks like this:
The wait code can be used in all different kinds of ways and isn't just for "If" checks, keep this in mind.
Now the full code looks like this:
:1
wait 0
if
0256: player $PLAYER_CHAR defined
jf @1
:2
0330: set_player $PLAYER_CHAR infinite_run 1
end_thread <-- i didnt put this in the above code because i wanted to explain the use of "Infinite Run", All "End thread" does is ends the thread. Stops the script in its tracks, To load your script after using an end thread code, you will have to start a new game or restart your game
wait 0
if
0256: player $PLAYER_CHAR defined
jf @1
:2
0330: set_player $PLAYER_CHAR infinite_run 1
end_thread <-- i didnt put this in the above code because i wanted to explain the use of "Infinite Run", All "End thread" does is ends the thread. Stops the script in its tracks, To load your script after using an end thread code, you will have to start a new game or restart your game
Now, this code we created sets the infinite run attribute to true at the start of the game and ends the script, A very simple execution.
To test your code press F8 when in Sanny Builder (Runs the game)
This ends "Tutorial 1 - The Basics"
To test your code press F8 when in Sanny Builder (Runs the game)
This ends "Tutorial 1 - The Basics"