FiXato's RPG Maker VX Ace Resources

RPG Maker VX Ace screenshot

Introduction

RPG Maker VX Ace box art

RPG Maker VX Ace has a lot of functions and options. Perhaps a frightening amount for the beginner. On this page I'll keep track of links, tips and tricks that have been useful to me.
If you want to support me, please purchase your RPG Maker VX Ace license through my affiliate link.
Now with 15% discount with coupon code: 15off

Page Contents

Script Equivalents of Events

You can achieve a lot of things through events using the RPG Maker VX Ace events interface, but what if you want to consolidate those things in a single script? Automate them from inside your script calls?
Stick around and read up on this list of game data, variable, game objects and event equivalents to learn how to achieve all those things through code instead of GUI.

Game Data

  • $data_actors

    Contains all the RPG::Actor objects (all available actors) and their Actor settings (name, nickname, face, face_id, class, etc)

  • $data_classes

    Array of RPG::Class objects which contain Class settings such as exp_for_level, exp_params, learnings and params.

  • $data_skills

    Array of RPG::Skill objects which contain Skill settings such as message1, message2, mp_cost, tp_cost, types and required types.

  • $data_items

    Array of RPG::Item objects which contain Item settings such as if it is consumable, get_item_count, itype_id, key_item? and price.

  • $data_weapons

    Array of RPG::Weapon objects which contain Weapon settings such as animation_id, performance and wtype_id.

  • $data_armors

    Array of RPG::Armor objects which contain Armor settings such as atype_id and performance.

  • $data_enemies

    Array of RPG::Enemy objects which contain Enemy settings such as actions, battler_hue, battler_name, drop_items, exp, gold and params.

  • $data_troops

    Array of RPG::Troop objects which contain Troop settings such as members, name and pages.

  • $data_states

    Array of RPG::State objects which contain State settings such as auto_removal_timing, chance_by_damage, max_turns, message1-4, min_turns, priority, remove_at_battle_end, remove_by_damage, remove_by_restriction, remove_by_walking, restriction and steps_to_remove.

  • $data_animations

    Array of RPG::Animation objects with Animation settings such as animation1_hue, animation1_name, animation2_name, animation2_hue, frame_max, frames, name, position, timings, to_screen? and similar setters.

  • $data_tilesets

    Array of RPG::Tileset objects with Tileset settings such as flags, id, mode, name, note and tileset_names.

  • $data_common_events

    Array of RPG::CommonEvent objects with Common Event settings such as autorun?, id, list, name, parallel?, switch_id and trigger.

  • $data_system

    RPG::System object which contains a plethora of System settings such as transport settings, armor types, battle details, currency unit, game title, follower settings, switches, etc.

  • $data_mapinfos

    Hash of all the maps in the game in the form of MapID to RPG::MapInfo mappings.

Game Objects

  • $game_temp

    Game_Temp object for temporary things such as triggering Common Events and fades.

  • $game_system

    Game_System object which contains GameSystem settings, such as the current sounds/music effects, encounters, playtime, save game details and version info.

  • $game_timer

    Game_Timer object useful for setting up timers.

  • $game_message

    Game_Message object, used for setting up messages and choices.

  • $game_switches

    Game_Switches object containing an array of True or False depending on whether the Game Switch is enabled or disabled. For example $game_switches[2] would get the game switch with ID 2.

  • $game_variables

    Game_Variables object which basically is an array of Game Variables. For example $game_variables[2] would get the game variable with ID 2.

  • $game_self_switches

    Game_SelfSwitches object; an Array of Game Control Self Switches for an event tile on a game map.
    Example use:
      $game_self_switches[[map_id,event_id,self_switch_letter]]
    where map_id is the Game Map id, event_id the Game Event id and self_switch_letter is a string indicating whether it is the 'A', 'B', 'C', or 'D' Control Self Switch.

  • $game_actors

    Game_Actors object; basically an array of all Game_Actor objects; the current Actors in the game and their Actor settings.

  • $game_party

    Game_Party object which you can use to add or remove actors from your Game Party; checking gold, armors, items, steps, weapons, etc; as well as containing Game Party settings.

  • $game_troop

    Game_Troop object containing the Enemies, their troop's gold_rate, gold_total, turn_count, etc. Handles enemy groups and battle-related data. Also performs battle events.

  • $game_map

    Game_Map object which controls the current Game map and its Game Map data. It includes scrolling and passage determination functions.

  • $game_player

    Game_Player object which includes event starting determinants and map scrolling functions. You can use it to find out who the main actor is, what your current coordinates are, your collision detection, control your movement, opacity/graphics, etc. For instance controls Character Commands and Movement Commands.

Variables

  • Game Variables

    Controls the Game Variables.

    $game_variables[n]
    Where 'n' is the Game Variable ID (without the leading zeroes)

    Examples:

    • # Get Game Variable 002
      $game_variables[2]
    • # Set Game Variable 002 to 3
      $game_variables[2] = 3
  • Game Switches

    Controls the Game Switches.

    $game_switches[n]
    Where 'n' is the Game Switch ID (without the leading zeroes)

    Examples:

    • # Get Game Switch 002
      $game_switches[2]
    • # Enable Game Switch 002
      $game_switches[2] = true
    • # Disable Game Switch 002
      $game_switches[2] = false
  • Conditional Branch

    Conditionally do things.

    if condition
      # whichever needs to be done when condition evaluates to true
    elsif other_condition
      #whichever needs to be done when condition is false and other_condition evaluates to true
    else
      #Whatever needs to be done if all above conditions are false.
    end
    Where 'condition' and 'other_condition' are variables, or more complex condition expressions. The 'elsif' statement is optional.

    Examples:

    • # Increase game variable 003 by 1 when game control switch 004 is enabled, else decrease it by 1
      if $game_switches[4]
        $game_variables[3] += 1
      else
        $game_variables[3] -= 1
    • # When game variable 003 is greater than 2, enable game control switch 004;
      # when game variable 003 is smaller than 0, disable game control switch 004,
      # else increase game variable 003 by 1.
      if $game_variables[3] > 2
        $game_switches[4] = true
      elsif $game_variables[3] < 0
        $game_switches[4] = false
      else
        $game_variables[3] += 1
  • Show Picture

    Show a picture on the game screen.

    screen.pictures[index].show(file_name, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
    screen is a Game_Screen instance. For instance $game_map.screen and $game_troop.screen are Game_Screen instances. Origin is the starting position, for instance upperleft (0) or center (1). Opacity is a decimal between 0 and 255.0 You can use 0 (normal), 1 (add) or 2 (subtract) as blend_type.

    Examples:

    • # screen.pictures[1].show("walkable.png", 1, $game_player.screen_x, $game_player.screen_y + 32, 100, 100, 255, 0)
  • Move Picture

    Move a picture on the game screen.

    screen.pictures[index].move(origin, x, y, zoom_x, zoom_y, opacity, blend_type, duration)
    screen is a Game_Screen instance. For instance $game_map.screen and $game_troop.screen are Game_Screen instances. Origin is the starting position, for instance upperleft (0) or center (1). Opacity is a decimal between 0 and 255.0 You can use 0 (normal), 1 (add) or 2 (subtract) as blend_type. You can specify the number of frames as 'durations'.

    Examples:

    • # screen.pictures[1].move(0, $game_player.screen_x, $game_player.screen_y + 32, 100, 100, 255, 0, 60)
  • Picture Tone Change (Tint Picture)

    Change the tone of a picture on the game screen.

    screen.pictures[index].start_tone_change(Tone.new(r, g, b, greyscale), duration)
    screen is a Game_Screen instance. For instance $game_map.screen and $game_troop.screen are Game_Screen instances. For the Tone you need to define decimals between 0 and 255.0 for the (r)ed, (g)reen, (b)lue and greyscale values. You can specify the number of frames as 'durations'.

    Examples:

    • # screen.pictures[1].start_tone_change(Tone.new(125, 125, 0, 0), 120)
  • Looping

    A continuous loop till you 'break' out of it or till 'condition' evaluates to false.

    while condition
      #The things you want to be done during the loop
    end
    Use with care. You don't want to be caught in an endless loop.

    Examples:

    • # Increment Game Variable 003 with 2 till it is greater than or equal to 10
      while $game_variables[3] < 10
        $game_variables[3] += 2
      end

    For more details, see: http://www.tutorialspoint.com/ruby/ruby_loops.htm

  • Loop something n times

    Looping for n times through code.

    n.times do |i|
      #The things you want to be done during the loop
    end
    Replace 'n' with the amount of times you want to run the loop. The |i| part is optional, but when you include it, the current index is stored in the local variable 'i'.

    Examples:

    • # Increment Game Variable 003 three times, with the index as amount
      3.times do |i|
        $game_variables[3] += i
      end

    For more details, see: http://rubymonk.com/learning/books/1-ruby-primer/chapters/8-control-structures/lessons/44-loops-in-ruby

  • Loop through an Array

    Do something with/for each element in an array, for instance for each of your items.

    array.each do |item|
      # Do something with item
    end
    Replace 'array' with the array variable you want to loop through. For each loop the current element will be stored in 'item' local variable. (Or whichever variable name is used between the |pipes|).

    Examples:

    • # Gain all the items and add a game_message line for each item gain.
      $data_items.compact.each do |item|
        $game_message.add("Gained item: #{item.name}")
        $game_party.gain_item(item.id, 1)
      end

    For more details, see: http://ruby-doc.org/core-1.9.3/Array.html#method-i-each

  • Move Event

    Create a new MoveRoute and make the GamePlayer follow it.

    move_route = RPG::MoveRoute.new
    move_route.repeat = false
    move_route.skippable = true
    m = RPG::MoveCommand.new
    m.code = 45 #The List of M Code can be found over Game_Character, this current m.code is call script
    m.parameters = ["Replace this with the name of a Game_Player#instance_method, for instance move_forward"]
    move_route.list.insert(0,m.clone)
    $game_player.force_move_route(move_route)
    The MoveRoute code is the type of Movement Command, in this case a Script call, which is specified in m.parameters. The given parameter should be the name of a instance method of Game_Player (which includes those of Game_Character, because Game_Player is a child of Game_Character). The full list of codes and their Movement Command types is specified in Game_Character:
      ROUTE_END               = 0             # End of Move Route
      ROUTE_MOVE_DOWN         = 1             # Move Down
      ROUTE_MOVE_LEFT         = 2             # Move Left
      ROUTE_MOVE_RIGHT        = 3             # Move Right
      ROUTE_MOVE_UP           = 4             # Move Up
      ROUTE_MOVE_LOWER_L      = 5             # Move Lower Left
      ROUTE_MOVE_LOWER_R      = 6             # Move Lower Right
      ROUTE_MOVE_UPPER_L      = 7             # Move Upper Left
      ROUTE_MOVE_UPPER_R      = 8             # Move Upper Right
      ROUTE_MOVE_RANDOM       = 9             # Move at Random
      ROUTE_MOVE_TOWARD       = 10            # Move toward Player
      ROUTE_MOVE_AWAY         = 11            # Move away from Player
      ROUTE_MOVE_FORWARD      = 12            # 1 Step Forward
      ROUTE_MOVE_BACKWARD     = 13            # 1 Step Backward
      ROUTE_JUMP              = 14            # Jump
      ROUTE_WAIT              = 15            # Wait
      ROUTE_TURN_DOWN         = 16            # Turn Down
      ROUTE_TURN_LEFT         = 17            # Turn Left
      ROUTE_TURN_RIGHT        = 18            # Turn Right
      ROUTE_TURN_UP           = 19            # Turn Up
      ROUTE_TURN_90D_R        = 20            # Turn 90 Degrees Right
      ROUTE_TURN_90D_L        = 21            # Turn 90 Degrees Left
      ROUTE_TURN_180D         = 22            # Turn 180 Degrees
      ROUTE_TURN_90D_R_L      = 23            # Turn 90 Degrees Right/Left
      ROUTE_TURN_RANDOM       = 24            # Turn at Random
      ROUTE_TURN_TOWARD       = 25            # Turn toward player
      ROUTE_TURN_AWAY         = 26            # Turn away from Player
      ROUTE_SWITCH_ON         = 27            # Switch ON
      ROUTE_SWITCH_OFF        = 28            # Switch OFF
      ROUTE_CHANGE_SPEED      = 29            # Change Speed
      ROUTE_CHANGE_FREQ       = 30            # Change Frequency
      ROUTE_WALK_ANIME_ON     = 31            # Walking Animation ON
      ROUTE_WALK_ANIME_OFF    = 32            # Walking Animation OFF
      ROUTE_STEP_ANIME_ON     = 33            # Stepping Animation ON
      ROUTE_STEP_ANIME_OFF    = 34            # Stepping Animation OFF
      ROUTE_DIR_FIX_ON        = 35            # Direction Fix ON
      ROUTE_DIR_FIX_OFF       = 36            # Direction Fix OFF
      ROUTE_THROUGH_ON        = 37            # Pass-Through ON
      ROUTE_THROUGH_OFF       = 38            # Pass-Through OFF
      ROUTE_TRANSPARENT_ON    = 39            # Transparent ON
      ROUTE_TRANSPARENT_OFF   = 40            # Transparent OFF
      ROUTE_CHANGE_GRAPHIC    = 41            # Change Graphic
      ROUTE_CHANGE_OPACITY    = 42            # Change Opacity
      ROUTE_CHANGE_BLENDING   = 43            # Change Blending
      ROUTE_PLAY_SE           = 44            # Play SE
      ROUTE_SCRIPT            = 45            # Script
    

    Examples:

    • # Move the game player down, left and down again:
        move_route = RPG::MoveRoute.new
        move_route.repeat = false
        move_route.skippable = true
        m = RPG::MoveCommand.new
        m.code = 1 #down
        move_route.list.insert(0,m.clone)
        m.code = 2 #left
        move_route.list.insert(0,m.clone)
        m.code = 1 #down
        move_route.list.insert(0,m.clone)
        $game_player.force_move_route(move_route)
    • # Move the game player forward, followed by 1 position randomly through a script call:
        move_route = RPG::MoveRoute.new
        move_route.repeat = false
        move_route.skippable = true
        m = RPG::MoveCommand.new
        m.code = 1 #down
        move_route.list.insert(0,m.clone)
        m.code = 45
        m.parameters = ["move_forward"]
        move_route.list.insert(0,m.clone)
        m.parameters = ["move_random"]
        move_route.list.insert(0,m.clone)
        $game_player.force_move_route(move_route)