Scripting 101, things you may want to know.
Index:
Section 1: Images.Section 2: Pokémon.
Hello, and welcome to Carmaniac's; Scripting, things you may want to know. In this thread, I shall be providing most functions within codes that people may want to know, but can't seem to find the help to learn it. For instance, how to show images, how to add in text, how to do checks for Pokémon, or anything else you guys would like to learn.
Section 1: Images.
In this section, we shall learn the basic commands on how to load up images. To begin with, we shall start by seeing what type of variables there are, that we can use to first, define an image. There's two different ways you can conduct this. You can create an array, to display the images, which, is easier to remove all the images when the script ends. Or you can use a standard variable to display the image. Examples below:
@sprites = {} #This line is crucial if you want to use the array method.
@sprites["Background"] = Sprite.new # This defines the variable is a new sprite.
@sprites["Background"].x = 20 # This sets the horizontal position, showing it as
# the value of 20.
@sprites["Background"].y = 100 # This sets the verticle position.
@sprites["Background"].z = 900 # This sets which layer the image is on, higher the
#number is, the higher the image is set above other images.
@sprites["Background"].bitmap = BitmapCache.load_bitmap("Graphics/FolderName/ImageName")
#This line is setting what the image will be, ("Graphics/FolderName/ImageName") is
#important as it directs the code to where the image is.
You can also manipulate the images in many ways. For example:
@sprites["Background"].zoom_x = 2
@sprites["Background"].zoom_y = 2
The lines above change the zoom size of the graphic by a scale of 2.
@sprites["Background"].angle = 0
Use this if you would like to change the angle of the image. You can also do fun things in the update
method of the script with this. For instance @sprites["Background"].angle+=1 with constantly
rotate the image.
@sprites["Background"].opacity = 255
This changes the opacity of the chosen image 255 being visible and 0 being invisible.
@Background = Sprite.new # Defines normal variable as a sprite
@Background.x = 20 # Defines the horizontal position.
@Background.y = 100 # Defines the verticle position.
@Background.z = 999 # Defines layer
@Background.bitmap = BitmapCache.load_bitmap("Graphics/FolderName/ImageName")
# Defines image path.
That is the basic information you need to know when it comes to displaying images.
Section 2: Pokémon.
In this section, we look at basic functions that relate to Pokémon. We shall be using functions from the previous section, to display the Pokémon, and also a new function of images will be included. Lets begin.
if $Trainer.party.length>=1
# This checks if you have 1 or more Pokémon.
@sprites["Pkm1"] = AnimatedSprite.new(sprintf("Graphics/Icons/icon%03d",$Trainer.party[0].species),2,128/2,64,2)
# This line is creating the image of the first Pokémon in the party.
# $Trainer.party[0].species is the first party, party numbers go 0-5.
@sprites["Pkm1"].x = 20
@sprites["Pkm1"].y = 20
@sprites["Pkm1"].z = 999
end
# This ends the check.
$Trainer.party[0].hp
This shows the current hp for the first Pokémon.
$Trainer.party[0].totalhp
This is the max hp value for the first Pokémon.
$Trainer.party[0].moves[0].pp
This is seeing the value of the first Pokémons' first move pp amount. Moves are shown in the values 0-3
0 being move 1 and 3 being move 4.
$Trainer.party[0].moves[0].totalpp
Checks the max amount of pp for the first move of Pokémon 1.
I will be adding more functions to this thread as I go along, for now, this is the basic info people may want. If you'd like anything else, please send a PM to me or post in this thread about what you would like, and I shall get back to you with the information on here.
Last edited: