The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Sthrattoff on February 15, 2009, 05:28:14 AM

Title: Module System to make your script structure looks neat.
Post by: Sthrattoff on February 15, 2009, 05:28:14 AM
This is just a simple script that enables you beginner scripter to add something. Currently I have two modules to publish. They are Game_System module and Victory Handler module. Here's the script:

[spoiler]#==============================================================================
# Game_System Add-On Module
#------------------------------------------------------------------------------
# © 2009 by Sthrattoff
#==============================================================================

# Description:
# This module modify Game_System so you can save your custom variables within
# save files.

class Game_System
 
  #Add attr_accessor of your variables here.
  attr_accessor :victory_points
 
  alias old_initialize initialize
  def initialize
    old_initialize
    # Set your initial variables values here.
    @victory_points = 0
  end
 
end

[/spoiler]

[spoiler]#==============================================================================
# Battle Victory Add-On Module
#------------------------------------------------------------------------------
# © 2009 by Sthrattoff
#==============================================================================

# Description:
# This module modify phase_5 of Scene_Battle which handle victory conditions.

class Scene_Battle
 
  alias old_start_phase5 start_phase5
  def start_phase5
    old_start_phase5
    #You can add anything you like to happen after victory here.
    $game_system.victory_points += 1
  end
 
end
[/spoiler]