Game Development Reference
In-Depth Information
Finding How RMVXA Handles Actor Names Within Its Code
First, we have to find out how RMVXA handles actor names within the code. A good place to start our search is the
code that governs the Conditional Branch command. After all, one of the possible conditionals involves inputted
names. Running a search in the Script Editor for “conditional branch” returns a single result. Click it and scroll down
until you find this part of the code.
when 4 # Actor
actor = $game_actors[@params[1]]
if actor
case @params[2]
when 0 # in party
result = ($game_party.members.include?(actor))
when 1 # name
result = (actor.name == @params[3])
From here, we learn that, whatever our end result looks like, it has to involve $game_actors in some capacity.
As it turns out, that is correct. There is a Game_Actors class within the Script Editor, but checking it out is largely
fruitless, save for one single tidbit: This is a wrapper for an actor array. An array in programming is a list of items. In this
case, Game_Actors combines all of the relevant actor information into a single array. What we want is a specific actor's
name, so let's head on over to Game_Actor , where we're almost immediately greeted by the information following:
attr_accessor :name # Name
attr_accessor :nickname # Nickname
attr_reader :character_name # character graphic filename
attr_reader :character_index # character graphic index
attr_reader :face_name # face graphic filename
attr_reader :face_index # face graphic index
attr_reader :class_id # class ID
attr_reader :level # level
attr_reader :action_input_index # action number being input
attr_reader :last_skill # For cursor memorization: Skill
attr_accessor , attr_reader , and attr_writer (not present in Game_Actor ) are a trio of Ruby modules that
allows for instance variables to be used outside of the classes in which they normally exist. For the purposes of this
exercise, all you have to know is that the listed attributes are contained within the array created by $game_actors . This
is what you would need to write in the Script box of Control Variables to fetch an actor's name: $game_actors[n].name
(where n is equal to the actor's ID in the Database).
You can also grab the other attributes in the same way. Just replace name with the attribute in question. level,
in particular, could be pretty useful in creating areas that can only be accessed if a player is of a certain level or higher.
Note
How to Use the Script Option to Store and Modify Text in a Variable
To be precise, we'll be storing an actor name within the Riddle1 variable, but this can be applied to any other type of
text you can think of. While the most common use of variables in RMVXA is to store numbers, text can fit in there just
fine. In any case, now that we know how to call for a specific actor's name, we can write that value into a variable by
using the Script option.
@>Control Variables: [0016:Riddle1] = $game_actors[11].name
 
 
Search WWH ::




Custom Search