Game Development Reference
In-Depth Information
That's what the event command should look like, once you're done ( 11 being the database ID of the new blank
actor for this specific exercise). Next, we have to make sure that the player receives a positive response for a correct
answer, no matter how it is written. There is a class within Ruby called String that contains various methods we can
use to modify text. You can check the appropriate help page within RMVXA for additional details, but the two we're
interested in are upcase and downcase . Suppose the player writes “Human” in the name input screen. If we modified
it with upcase , it would become “HUMAN.” On the other hand, downcase would turn it into “human.” For this exercise,
I'll be using downcase . What we want to do is modify the contents of the Riddle1 variable after the previously pictured
event command has been processed. It's as simple as doing the following:
Finding Script on page 3 of the event command list
Writing in
$game_variables[16] = $game_variables[16].downcase (or whichever variable
ID you are using for your riddle)
Make sure that you don't split a single expression in twain while scripting. In the following lines of script, the
first example is correct; the second is incorrect.
Note
@>Script: $game_variables[16] =
: : $game_variables[16].downcase
@>Script: $game_variables[16] = $game_variables
: : [16].downcase
It's easier if you think of the preceding as three separate expressions. $game_variables[16] is the first one,
the equal sign is the second, and applying the downcase method to $game_variables is the third. RMVXA reads the
second example as four expressions, as you're cutting the third into two halves.
Finishing Up Our Riddle Event
Next, we need a conditional branch, to check if the value of our riddle variable is equal to human (if you used
upcase instead of downcase , you'll want to check for HUMAN instead). We use the script option and write out
$game_variables[16] = "human" (make sure you include the quotation marks). In this particular case, you can either
check “Set handling when conditions do not apply” or have another conditional branch for $game_variables[16]
!= "human" ( != is “not equal” in Ruby). In either case, the last thing that requires scripting is emptying out the actor
name. To do this, we have another line of script: $game_actors[11].name = ""
The quotation marks are important here as well. If you leave the method assignment completely empty, the game
will crash with an error. Here's what the skeleton of the completed event looks like:
@>Text: -, -, Normal, Bottom
: : What is that which has one voice and yet becomes
: : four-footed and two-footed and three-footed?
@>Name Input Processing: , 5 characters
@>Control Variables: [0016:Riddle1] = $game_actors[11].name
@>Script: $game_variables[16] =
: : $game_variables[16].downcase
 
 
Search WWH ::




Custom Search