Learning RGSS3
I'm putting together a little page mostly for myself as a reference guide for RGSS3. Its the programming language used by RPG Maker VX Ace. Its a derivative of Ruby.
Variables
Variable Scopes:
The scope of a variable is set by the symbol in front of the variable name when it is declared and used.
local
@instance
$global
CONSTANT
You can use +=, -=, *=, and /= to change the value as in: myVar += 5 => myVar = myVar + 5
Array
Arrays may have mixed data types.
To append information to an array simply assign a value to an unused array index.
To create an array of length x+1
To get the length of an array
Flow Control Statements
If Statement:
Available boolean operators: ==, <=, >=, <, >, !=
To check multiple booleanExpressions in an if statement use && for and and || for or.
Methods
Creating a method:
Return is optional at the end of a method.
Calling a method:
Classes
Playing Sounds
To play background music:
To play background sound:
To play a music effect:
To play a sound effect:
Volume range: 0-100
Pitch range: 5-200
Variable Scopes:
The scope of a variable is set by the symbol in front of the variable name when it is declared and used.
local
@instance
$global
CONSTANT
You can use +=, -=, *=, and /= to change the value as in: myVar += 5 => myVar = myVar + 5
Array
Arrays may have mixed data types.
To append information to an array simply assign a value to an unused array index.
To create an array of length x+1
- array = [0,1,...,x]
To get the length of an array
- array.size()
Flow Control Statements
If Statement:
- if booleanExpression
- expression
- else
- expression
- end
- expression if booleanExpression
Available boolean operators: ==, <=, >=, <, >, !=
To check multiple booleanExpressions in an if statement use && for and and || for or.
Methods
Creating a method:
- def methodName(variable1, variable2=defaultValue)
- expression
- return value
- end
Return is optional at the end of a method.
Calling a method:
- methodName()
Classes
- class className
- def initialize() expression
- end
- def dispose() expression
- end
Playing Sounds
To play background music:
- Audio.bgm_play(filePath, intVolume, intPitch)
- RPG::BGM.new(fileName, intVolume, intPitch).play
To play background sound:
- Audio.bgs_play(filePath, intVolume, intPitch)
- RPG::BGS.new(fileName, intVolume, intPitch).play
To play a music effect:
- Audio.me_play(filePath, intVolume, intPitch)
- RPG::ME.new(fileName, intVolume, intPitch).play
To play a sound effect:
- Audio.se_play(filePath, intVolume, intPitch)
- RPG::SE.new(fileName, intVolume, intPitch).play
Volume range: 0-100
Pitch range: 5-200