API reference
What the loader exposes to your main.rb, plus the most useful global game objects.
The ModLoader module
The loader itself runs as a module called ModLoader. Your mod can call into
it for logging, asset lookup, and to inspect what other mods loaded.
ModLoader.log(msg)
Writes msg to every active log file with a timestamp. Returns nil. Always
wrap in rescue nil in case your mod is ever loaded outside the patched game.
ModLoader.log("[my_mod] booted, hooked 3 classes") rescue nil
ModLoader.loaded
Array of folder names of mods that loaded successfully this session.
ModLoader.errors
Array of [mod_name, exception] tuples for mods that threw during load.
ModLoader.find_asset_override(path)
Returns the absolute file system path of an asset override registered by some mod, or
nil if no mod overrides this path. Useful if you're writing a mod that wants
to compose with another mod's overrides.
full = ModLoader.find_asset_override("Graphics/Faces/Alice")
# => "C:/.../Mods/skin_pack/assets/Graphics/Faces/Alice.png"
# or nil if no mod claims it
ModLoader.asset_overrides
The full hash of relative_path => absolute_path. Read-only - don't mutate.
Useful RGSS3 globals
$game_party
The active party. Members are Game_Actor instances; the array is
$game_party.members.
| Method | Notes |
|---|---|
members | Array of party actors. |
gold | Current souls. |
gain_gold(n) | Add n. Negative subtracts. |
lose_gold(n) | Subtract n. |
gain_item(item, n) | item is an RPG::Item / Weapon / Armor. |
lose_item(item, n) | - |
item_number(item) | How many of that item we own. |
add_actor(id) / remove_actor(id) | Modify roster. |
$game_player
The on-map player avatar (a Game_Player).
| Method / attr | Notes |
|---|---|
x / y | Tile coords. |
direction | 2 down / 4 left / 6 right / 8 up. |
reserve_transfer(map_id, x, y, dir) | Teleport to another map. |
@through (ivar) | Set true to walk through walls. BS2 strips the public setter; use $game_player.instance_variable_set(:@through, true). |
increase_steps | Hooked by the 01_simple_ruby template - runs on every move. |
$game_map
| Method | Notes |
|---|---|
map_id | Current map ID. |
refresh | Re-evaluate all events on the map. |
passable?(x, y, d) | Tile passability. |
events | Hash {event_id => Game_Event}. |
$game_switches[id] and $game_variables[id]
RPG Maker switch and variable tables. 1-indexed. $game_switches[1] = true flips story flag #1.
$data_*
The database arrays. 1-indexed (entry 0 is nil).
$data_items- RPG::Item (consumables, key items)$data_weapons- RPG::Weapon$data_armors- RPG::Armor$data_skills- RPG::Skill$data_enemies- RPG::Enemy$data_classes- RPG::Class$data_states- RPG::State$data_actors- RPG::Actor$data_troops- RPG::Troop$data_mapinfos- Hash{map_id => RPG::MapInfo}$data_system- RPG::System (game title, switches/variables names, sounds, etc.)$data_common_events- Array of common events
SceneManager
| Method | Notes |
|---|---|
SceneManager.call(SomeScene) | Push a new scene; current scene returns when the new one finishes. |
SceneManager.return | Pop back to the previous scene. |
SceneManager.scene_is?(SomeClass) | Type check on the active scene. |
BS2-specific systems
KURE::ShortMove::MOVE_LIST
The bonfire / fast-travel destination list. Array of [label_meta, target]
pairs where target is [map_id, x, y, dir]. Used by the
creative_mode mod's teleport menu.
KURE::ShortMove::MOVE_LIST.each do |entry|
next unless entry.is_a?(Array) && entry.size >= 2
name = entry[0].is_a?(Array) ? entry[0][0].to_s : entry[0].to_s
map_id, x, y, dir = entry[1]
# ... use the destination
end
Spirits and Spirits::Features
BS2's covenant / partner system. Spirits.actor_id(spirit_id) maps a spirit ID
to the corresponding actor ID. Scene_EditPartner opens the partner-change UI.
Class / method discovery
Don't memorize the BS2 class hierarchy - generate it. The recon tool dumps every script in the game and produces an auto-indexed reference:
cd "Mod Loader/src"
python recon.py
Output: docs/recon/scripts/*.rb (224 readable Ruby files) and
docs/recon/DOCUMENTATION.md (every class, module, method, and constant
indexed by which script defines it).