MACL - Method and Class Library 2.3

What I did with making a battler is basically this:
class Game_Character
  attr_accessor :battler
  def initialize
    [..]
    @battler = Game_Battler.new
  end
end

class Game_Event
  def setup_battler #In the event name, make [xx] where xx is the two-digit index of the battler
    if @event.name =~ /\[[ ]*([00-99]+)\]/i
      @battler = Game_Battler.new($1)
    end
  end
end

class Game_Player
  #--------------------------------------------------------------------------
  # * Setup Battler : Connect Battler to Player
  #--------------------------------------------------------------------------
  def setup_battler
    @battler = $game_party.actors[0]
  end
end
Expand to see the code.

I did not actually provide for calling setup_battler; not sure where it does get called, actually.  Just went into the project to find it, the only place I used it is in Scene_Title:
  #-------------------------------------------------------------------------- #****
  # * Command: New Game : Party Setup
  #--------------------------------------------------------------------------
  def commandnewgame_partysetup
    # Set up initial party
    $game_player.setup_battler
  end
Expand to see the code.

Because, since I only have one party member, ever, I'm getting rid of $game_party and migrating all its functions to Game_Battler (also getting rid of the Actor/Enemy distinction, but I've made sure all the functions I just gave you correlate to the default script setup)
Ok. I'll check into Window Sprites and Moveable.

It was in RGSS.Character under Game_Character, the update method, it also calls refresh. Silly.

@mew: Pretty cool stuff.
SephirothSpawn wrote:
@Charlie Lee: Not a bad idea. I might modify that to make it more dynamic and customizable.
[...]
How's that work?


:straightthumb:
As a development of my initial idea i was thinking about creating two types of shortcuts. The first one is this one, which only moves the cursor; a second one could even trigger the command. However the command selection is usually done within the scenes code, so what could be done in the MACL would be only to provide a support for it... maybe a variable to be checked by the scene code. Opinions?
I skimmed through the text file and I couldn't anything related to this; and obviously I shouldn't post this in the request forum...anyhow:

A Geometry module containing basic data structures would be appreciated. Sure, there are some draw methods, but that's about it. Having a nicely contained, basic module would be nice; things like Point, Line, Polygon, Ellipse, Circle (yes, I know, it's an Ellipse, but I think the equations are computed in a more efficient manner than with the ellipse), etc.

It's not necessary, I suppose, but it eases development, handling and code logic.
I was actually thinking of going through my old college math books and adding some things to the MACL, but it's not really a priority right now, so that will probably be in the 2.5 version.
Y'know what you should throw into the 2.5 version? I think the main section of the MACL you should add some re-writes to the SDK (if defined), namely the .check_requirements() method. I want to be able to use SDK.check_requirements() to check for MACL scripts. So if MACL.loaded?('RGSS.Map'), then it'll execute the script as long as we've got 'RGSS.Map' loaded. It' should obviously still work like it normally does, but the overwrite would check MACL scripts in question too.
I have thought of this in the past. The only thing is, every part of the MACL is included. Unlike the SDK, the MACL is a collection of methods. The SDK is method splits. So including individual methods would be a ton of work. So as is right now, every method is included, so of course MACL.loaded.include?('RGSS.Map') (which isn't much longer than what you suggested) will return true.

Unless I am missing what you are saying. I will add some SDK-typed methods in there, but in all honesty I don't think they will be very useful. The only thing I can see anyone not including, would be the modules/systems (like if someone uses a different keyboard).
Rewritting SDK.check_requirements for MACL Parts Spoiler
SephirothSpawn wrote:
I have thought of this in the past. The only thing is, every part of the MACL is included.


...I hope you weren't thinking I was talking about checking for every method did you? That'd be tedious, I'm just talking about checking something like "Do you have 'RGSS.Whatever' in your project"? If not, then it would return some kinda error message like...

"'Your Script' was disabled for the following reason.
You are missing these parts of the Method & Class Library :

['RGSS.Example']"

Whenever something like the following example is called...

MACL::Loaded << "RGSS.Whatever"

Then it is loaded, but if somebody doesn't have that section it is never called into the MACL::Loaded array, because obviously MACL::Loaded << is called within the script itself, so it'll return false. All it needs is to disable the script then print a formatted error message, telling you that you need "RGSS.Example" to run "Your Script".

Since SDK is primarily something in which methods like this are already used, and since MACL Libraries are placed below SDK, you could overwrite the methods directly, if defined?(SDK) like so...

if defined?(:SDK)

module SDK
  # Overwrite check_requirements
end

end
Expand to see the code.


...and be able to check both SDK Enabled Scripts and MACL sections simultaneously.


^^I've actually started something like this earlier, and it sorta works like what I was trying to describe but its not ready yet. However, while I'm still tinkering with it I'll submit some other stuff you might enjoy.

'Ruby.Numeric.strings' new methods Spoiler
#===============================================================================
# ** Ruby.Numeric.strings
#-------------------------------------------------------------------------------
#   Created some additional methods for the Numeric class, which is the parent
# class to all number-related classes. All of these methods deal with turning
# a number into some kind of formatted string form.
#
# Method List
# -----------
#   format_s
#   precise_s
#   percent_s
#   currency_s
#
#===============================================================================

MACL::Loaded << "Ruby.Numeric.strings"

#===============================================================================
# ** Numeric
#===============================================================================

class Numeric < Object
  #-----------------------------------------------------------------------------
  # * Name      : Format String
  #   Info      : Returns formatted string (exp; 1234.56 => "1,234.56")
  #   Author    : Kain Nobel
  #   Call Info : Float true will return float, false returns no floating value
  #-----------------------------------------------------------------------------
  def format_s(float = true)
    begin
      parts = self.to_s.split('.')
      parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")
      return parts.length == 2 && float ? parts[0]+"."+parts[1] : parts[0]
    rescue
      return self
    end
  end
  #-----------------------------------------------------------------------------
  # * Name      : Precise
  #   Info      : Returns number to a precise ammount
  #   Author    : Kain Nobel
  #   Call Info : Digits if positive shows this many float digits
  #               Digits if negative rounds integer back this many digits
  #-----------------------------------------------------------------------------
  def precise_s(digits = 2)
    return "%01.#{digits}f"%((Float(self)*(10**digits)).round.to_f/10**digits)
  end
  #-----------------------------------------------------------------------------
  # * Name      : Percent
  #   Info      : Return number as a percent string
  #               (Example: (100 / 8.0).percent #=> "12.5 %")
  #   Author    : Kain Nobel
  #   Call Info : Max is what the percent is comparing to
  #               Tolerence is the ammount of float to show (Default 0)
  #-----------------------------------------------------------------------------
  def percent_s(tolerence = 0, format = false)
    begin
      return format ? self.format_s+"%" : self.to_s+"%"
    rescue
      return self
    end
  end
  #-----------------------------------------------------------------------------
  # * Name      : Currency
  #   Info      : Returns currency string (exp; "$1,234.56")
  #   Author    : Kain Nobel
  #   Call Info : Sign is the currency symbol, for instance "$" or "Yen" or w/e
  #               Tail true sign is pinned to end, false sign pinned to start
  #-----------------------------------------------------------------------------
  def currency(sign = nil, tail = false)
    sign = "$" if !sign.is_a?(String)
    tail = self.to_i.zero? || tail
    begin
      if tail ; return (self.precise_s(2).to_f).format_s+" "+sign
      else    ; return sign+" "+(self.precise_s(2).to_f).format_s
      end
    rescue
      return sign+" "+self.to_s
    end
  end
end
Expand to see the code.


'RGSS.Character.MoveTest' Spoiler
#===============================================================================
# ~** Character Move Test **~
#-------------------------------------------------------------------------------
# Written By  : Kain Nobel
# Version     : 2.0
# Last Update : 09.02.2008
#===============================================================================
# Description
# -----------
#
#   This is a special set of methods, that will tell you which direction a
#   character or event is moving, and supports both 4 and 8 directional movement
#   checking.
#
#   When checking something like $game_map.events[1].moving_down?, you have the
#   optional argument 'diag'. If you set this argument as 'true' and a player is
#   moving_lower_left, then it'll return false, else it'll return true for both.
#
#   Also, for Game_Player, we've got additional methods for checking if player
#   is 'attempting' to move a certain direction. This is for scripts that want
#   to know, "Is he just 'attempting' to move left, or is he 'really' moving
#   left? So, it doesn't check for Input, rather it'll check for Movement AND
#   Input.
#
# Methods List
# -------------
# Game_Character
#   moving_down?
#   moving_left?
#   moving_right?
#   moving_up?
#   moving_upper_left?
#   moving_upper_right?
#   moving_lower_left?
#   moving_lower_right?
#   move_direction
#   moving_diagonal?
#
# Game_Player (< Game_Character)
#   attempt_down?
#   attempt_left?
#   attempt_right?
#   attempt_up?
#   attempt_upper_left?
#   attempt_upper_right?
#   attempt_lower_left?
#   attempt_lower_right?
#   attempt_moving?
#   attempt_direction?
#   attempt_diagonal?
#
#===============================================================================
#-------------------------------------------------------------------------------
# * SDK Log
#-------------------------------------------------------------------------------
SDK.log('RGSS.Character.MoveTest', 'Kain Nobel', 2.0, '09.21.2008')
#-------------------------------------------------------------------------------
# * SDK Enabled Test - BEGIN
#-------------------------------------------------------------------------------
if SDK.enabled?('RGSS.Character.MoveTest')
#===============================================================================
# ** Game_Character
#-------------------------------------------------------------------------------
#   The parent superclass of Game_Player and Game_Event has been modified to
# return detailed information on which direction a character is moving.
#===============================================================================
class Game_Character
  #-----------------------------------------------------------------------------
  # * Moving Down?
  #-----------------------------------------------------------------------------
  def moving_down?(diag = false)
    if diag ; return (self.real_y < self.y*128) && (self.real_x == self.x*128)
    end ; return (self.real_y < self.y * 128)
  end
  #-----------------------------------------------------------------------------
  # * Moving Left?
  #-----------------------------------------------------------------------------
  def moving_left?(diag = false)
    if diag ; return (self.real_x > self.x*128) && (self.real_y == self.y*128)
    end ; return (self.real_x > self.x * 128)
  end
  #-----------------------------------------------------------------------------
  # * Moving Right?
  #-----------------------------------------------------------------------------
  def moving_right?(diag = false)
    if diag ; return (self.real_x < self.x*128) && (self.real_y == self.y*128)
    end ; return (self.real_x < self.x * 128)
  end
  #-----------------------------------------------------------------------------
  # * Moving Left?
  #-----------------------------------------------------------------------------
  def moving_up?(diag = false)
    if diag ; return (self.real_y > self.y*128) && (self.real_x == self.x*128)
    end ; return (self.real_y > self.y * 128)
  end
  #-----------------------------------------------------------------------------
  # * Moving Lower Left?
  #-----------------------------------------------------------------------------
  def moving_lower_left?
    return (self.real_y < self.y * 128) && (self.real_x > self.x * 128)
  end
  #-----------------------------------------------------------------------------
  # * Moving Lower Right?
  #-----------------------------------------------------------------------------
  def moving_lower_right?
    return (self.real_y < self.y * 128) && (self.real_x < self.x * 128)
  end
  #-----------------------------------------------------------------------------
  # * Moving Lower Left?
  #-----------------------------------------------------------------------------
  def moving_upper_left?
    return (self.real_y > self.y * 128) && (self.real_x > self.x * 128)
  end
  #-----------------------------------------------------------------------------
  # * Moving Lower Right?
  #-----------------------------------------------------------------------------
  def moving_upper_right?
    return (self.real_y > self.y * 128) && (self.real_x < self.x * 128)
  end
  #-----------------------------------------------------------------------------
  # * Move Direction?
  #-----------------------------------------------------------------------------
  def move_direction
    return 2 if moving_down?
    return 4 if moving_left?
    return 6 if moving_right?
    return 8 if moving_up?
    return 1 if moving_lower_left?
    return 3 if moving_lower_right?
    return 7 if moving_upper_left?
    return 9 if moving_upper_right?
    return 0
  end
  #-----------------------------------------------------------------------------
  # * Moving Diagonal?
  #-----------------------------------------------------------------------------
  def moving_diagonal?
    return true if moving_upper_left? or moving_upper_right?
    return true if moving_lower_left? or moving_lower_right?
    return false
  end
end

#===============================================================================
# ** Game_Player
#-------------------------------------------------------------------------------
#   The child class of Game_Character, returns user's directional input to tell
# you if they're 'attemtping' to move a certain direction.
#===============================================================================
class Game_Player < Game_Character
  #-----------------------------------------------------------------------------
  # * Attempt Down?
  #-----------------------------------------------------------------------------
  def attempt_down?(diag = false)
    unless Input.press?(Input::LEFT) || Input.press?(Input::RIGHT)
      return Input.press?(Input::DOWN)
    end ; return false
  end
  #-----------------------------------------------------------------------------
  # * Attempt Left?
  #-----------------------------------------------------------------------------
  def attempt_left?(diag = false)
    unless Input.press?(Input::UP) || Input.press?(Input::DOWN)
      return Input.press?(Input::LEFT)
    end ; return false
  end
  #-----------------------------------------------------------------------------
  # * Attempt Right?
  #-----------------------------------------------------------------------------
  def attempt_right?(diag = false)
    unless Input.press?(Input::UP) || Input.press?(Input::DOWN)
      return Input.press?(Input::RIGHT)
    end ; return false
  end
  #-----------------------------------------------------------------------------
  # * Attempt Up?
  #-----------------------------------------------------------------------------
  def attempt_up?(diag = false)
    unless Input.press?(Input::LEFT) || Input.press?(Input::RIGHT)
      return Input.press?(Input::UP)
    end ; return false
  end
  #-----------------------------------------------------------------------------
  # * Attempt Upper Left?
  #-----------------------------------------------------------------------------
  def attempt_upper_left?
    m = Input.press?(Input::UP) && Input.press?(Input::LEFT)
    if defined?(Aleworks) && !m ; m = Input.press?(Input::UPPER_LEFT)
    end ; return m
  end
  #-----------------------------------------------------------------------------
  # * Attempt Upper Right?
  #-----------------------------------------------------------------------------
  def attempt_upper_right?
    m = Input.press?(Input::UP) && Input.press?(Input::RIGHT)
    if defined?(Aleworks) && !m ; return Input.press?(Input::UPPER_RIGHT)
    end ; return m
  end
  #-----------------------------------------------------------------------------
  # * Attempt Lower Left?
  #-----------------------------------------------------------------------------
  def attempt_lower_left?
    m = Input.press?(Input::DOWN) && Input.press?(Input::LEFT)
    if defined?(Aleworks) && !m ; return Input.press?(Input::LOWER_LEFT)
    end ; return m
  end
  #-----------------------------------------------------------------------------
  # * Attempt Lower Right?
  #-----------------------------------------------------------------------------
  def attempt_lower_right?
    m = Input.press?(Input::DOWN) && Input.press?(Input::RIGHT)
    if defined?(Aleworks) && !m ; return Input.press?(Input::LOWER_RIGHT)
    end ; return m
  end
  #-----------------------------------------------------------------------------
  # * Attempt Moving?
  #-----------------------------------------------------------------------------
  def attempt_moving?(diag = false)
    return true if attempt_down?(diag)
    return true if attempt_left?(diag)
    return true if attempt_right?(diag)
    return true if attempt_up?(diag)
    return attempt_diagonal?
  end
  #-----------------------------------------------------------------------------
  # *  Attempt Direction
  #-----------------------------------------------------------------------------
  def attempt_direction?
    if    attempt_down?         ; return 2
    elsif attempt_left?         ; return 4
    elsif attempt_right?        ; return 6
    elsif attempt_up?           ; return 8
    elsif attempt_lower_left?   ; return 1
    elsif attempt_lower_right?  ; return 3
    elsif attempt_upper_left?   ; return 7
    elsif attempt_upper_right?  ; return 9
    else                        ; return 0
    end
  end
  #-----------------------------------------------------------------------------
  # * Attempt Diagonal?
  #-----------------------------------------------------------------------------
  def attempt_diagonal?
    return true if attempt_upper_left?
    return true if attempt_upper_right?
    return true if attempt_lower_left?
    return true if attempt_lower_right?
    return false
  end
  #-----------------------------------------------------------------------------
  # * Attempt Print Test
  #-----------------------------------------------------------------------------
  def attempt_print_test(diag = false)
    print("Down : "+attempt_down?(diag).to_s+
    "\nLeft : "+attempt_left?(diag).to_s+
    "\nRight : "+attempt_right?(diag).to_s+
    "\nUp : "+attempt_up?(diag).to_s+
    "\nUpRight : "+attempt_upper_right?.to_s+
    "\nUpLeft : "+attempt_upper_left?.to_s+
    "\nDownRight : "+attempt_lower_right?.to_s+
    "\nDownLeft : "+attempt_lower_left?.to_s)
  end
end
#-------------------------------------------------------------------------------
# * SDK Enabled Test - END
#-------------------------------------------------------------------------------
end
Expand to see the code.


'RGSS.Actor and Party Info' additions Spoiler
#==============================================================================
# ** RGSS.Actor and Party Info
#------------------------------------------------------------------------------
# Description:
# ------------
# These set of methods add observer methods to the Game_Actor and Game_Party
# classes, you can get information on how weak an enemy is to a state, all
# of the enemies resistances and weaknesses, etc.
#
# Method List:
# ------------
#
#   Game_Actor
#   ----------
#   exp_s
#   next_exp_s
#   next_rest_exp_s
#   now_exp
#   next_exp
#   weapon_set
#   armor_set
#   weapon_stats()
#   armor_stats
#   strongest_weapon
#   weakest_weapon
#   strongest_armor
#   weakest_armor
#
#   Game_Party
#   ----------
#   average()
#   gain_all()
#   lose_all
#
#==============================================================================

MACL::Loaded << 'RGSS.Actor and Party Info'

#===============================================================================
# ** Game_Actor
#===============================================================================
class Game_Actor < Game_Battler
  #-----------------------------------------------------------------------------
  # * Public Instance Variables
  #-----------------------------------------------------------------------------
  attr_accessor :weapon_id
  attr_accessor :armor1_id
  attr_accessor :armor2_id
  attr_accessor :armor3_id
  attr_accessor :armor4_id
  #-----------------------------------------------------------------------------
  # * Name      : Experience
  #   Info      : Returns '@exp_list[@level+1]'
  #   Author    : Kain Nobel
  #   Call Info : None
  #-----------------------------------------------------------------------------
  def exp_list
    return @exp_list[@level+1]
  end
  #--------------------------------------------------------------------------
  # * Name      : Experience String (Overwrite)
  #   Info      : Returns Experience String
  #   Author    : Kain Nobel
  #   Call Info : Format will format experience string with commas
  #--------------------------------------------------------------------------
  def exp_s(format = true)
    return exp_list > 0 ? format ? @exp.format_s : @exp.to_s : "Master"
  end
  #--------------------------------------------------------------------------
  # * Name      : Next Experience String (Overwrite)
  #   Info      : Returns Experience String
  #   Author    : Kain Nobel
  #   Call Info : Format will format experience string with commas
  #--------------------------------------------------------------------------
  def next_exp_s(format = true)
    return exp_list > 0 ? format ? exp_list.format_s : exp_list.to_s : "Master"
  end
  #--------------------------------------------------------------------------
  # * Name      : Next Rest Experience String (Overwrite)
  #   Info      : Returns Experience String
  #   Author    : Kain Nobel
  #   Call Info : Format will format experience string with commas
  #--------------------------------------------------------------------------
  def next_rest_exp_s
    return exp_list > 0 ? format ? (exp_list-@exp).format :
    (exp_list-@exp).to_s : "Master"
  end
  #--------------------------------------------------------------------------
  # * Name      : Now Experience
  #   Info      : Returns current Experience
  #   Author    : Kain Nobel
  #   Call Info : None
  #-----------------------------------------------------------------------------
  def now_exp
    return @exp - @exp_list[@level]
  end
  #-----------------------------------------------------------------------------
  # * Name      : Next Experience
  #   Info      : Returns Experience to Next Level
  #   Author    : Kain Nobel
  #   Call Info : None
  #-----------------------------------------------------------------------------
  def next_exp
    return exp_list > 0 ? exp_list - @exp_list[@level] : 0
  end
  #-----------------------------------------------------------------------------
  # * Name      : Weapon Set
  #   Info      : Returns all weapon objects for an actor's class
  #   Author    : Kain Nobel
  #   Call Info : None
  #-----------------------------------------------------------------------------
  def weapon_set
    return $data_classes[@class_id].weapon_set
  end
  #-----------------------------------------------------------------------------
  # * Name      : Armor Set
  #   Info      : Returns all armor objects for an actor's class
  #   Author    : Kain Nobel
  #   Call Info : Kind ID for the Armors to check
  #-----------------------------------------------------------------------------
  def armor_set(kind = nil)
    if kind.nil?
      return $data_classes[@class_id].armor_set
    end
    armors = []
    ($data_classes[@class_id].armor_set).each do |armor|
      armors.push(armor) if $data_armors[armor].kind == kind
    end
    return armors
  end
  #-----------------------------------------------------------------------------
  # * Name      : Weapon Stats
  #   Info      : Returns a list of desired stats for the actor's weapon set
  #   Author    : Kain Nobel
  #   Call Info : Parameter is a string representing parameter in question
  #-----------------------------------------------------------------------------
  def weapon_stats(parameter)
    stats = []
    weapon_set.each do |i|
      if $game_party.weapons.include?(i)
        case (parameter.to_s)
        when 'name' ; stats.push($data_weapons[i].name)
        when 'price'; stats.push($data_weapons[i].price)
        when 'atk'  ; stats.push($data_weapons[i].atk)
        when 'pdef' ; stats.push($data_weapons[i].pdef)
        when 'mdef' ; stats.push($data_weapons[i].mdef)
        when 'str'  ; stats.push($data_weapons[i].str_plus)
        when 'dex'  ; stats.push($data_weapons[i].dex_plus)
        when 'agi'  ; stats.push($data_weapons[i].agi_plus)
        when 'int'  ; stats.push($data_weapons[i].int_plus)
        else ; print(":"+parameter+": is not a valid parameter when\n",
        "checking for $game_actor["+@actor_id.to_s+"].weapon_set()")
        end
      end
    end
    return stats.sort!
  end
  #-----------------------------------------------------------------------------
  # * Name      : Armor Stats
  #   Info      : Returns a list of desired stats for an actor's armor set
  #   Author    : Kain Nobel
  #   Call Info : Parameter is a string representing parameter in question
  #               Kind refers to the kind of amror it is
  #-----------------------------------------------------------------------------
  def armor_stats(parameter, kind = 0)
    stats = []
    armor_set.each do |i|
      if $data_armors[i].kind == kind && $game_party.armors.include?(i)
        case (parameter.to_s)
        when 'name' ; stats.push($data_armors[i].name)
        when 'price'; stats.push($data_armors[i].price)
        when 'atk'  ; stats.push($data_armors[i].atk)
        when 'pdef' ; stats.push($data_armors[i].pdef)
        when 'mdef' ; stats.push($data_armors[i].mdef)
        when 'str'  ; stats.push($data_armors[i].str_plus)
        when 'dex'  ; stats.push($data_armors[i].dex_plus)
        when 'agi'  ; stats.push($data_armors[i].agi_plus)
        when 'int'  ; stats.push($data_armors[i].int_plus)
        else ; print(":"+parameter+": is not a valid parameter when\n",
        "checking for $game_actor["+@actor_id.to_s+"].armor_set()")
        end
      end
    end
    return stats.sort!
  end
  #-----------------------------------------------------------------------------
  # * Name      : Strongest Weapon
  #   Info      : Returns the strongest weapon, based on parameter
  #   Author    : Kain Nobel
  #   Call Info : Parameter is a string representing parameter in question
  #-----------------------------------------------------------------------------
  def strongest_weapon(parameter)
    w = weapon_stats(parameter)
    return w[-1]
  end
  #-----------------------------------------------------------------------------
  # * Name      : Strongest Armor
  #   Info      : Returns the strongest armor, based on parameter
  #   Author    : Kain Nobel
  #   Call Info : Parameter is a string representing parameter in question
  #               Kind refers to the kind of amror it is
  #-----------------------------------------------------------------------------
  def strongest_armor(parameter, kind = 0)
    a = armor_stats(parameter, kind)
    return a[-1]
  end
  #-----------------------------------------------------------------------------
  # * Name      : Weakest Weapon
  #   Info      : Returns the weakest weapon, based on parameter
  #   Author    : Kain Nobel
  #   Call Info : Parameter is a string representing parameter in question
  #-----------------------------------------------------------------------------
  def weakest_weapon(parameter)
    w = weapon_stats(parameter)
    return w[0]
  end
  #-----------------------------------------------------------------------------
  # * Name      : Weakest Armor
  #   Info      : Returns the weakest armor, based on parameter
  #   Author    : Kain Nobel
  #   Call Info : Parameter is a string representing parameter in question
  #               Kind refers to the kind of amror it is
  #-----------------------------------------------------------------------------
  def weakest_armor(parameter, kind = 0)
    a = armor_stats(parameter, kind)
    return a[0]
  end
end

#===============================================================================
# ** Game_Party
#===============================================================================

class Game_Party
  #-----------------------------------------------------------------------------
  # * Public Instance Variables
  #-----------------------------------------------------------------------------
  attr_accessor :gold # This is set so you can do $game_party.gold = n
  #-----------------------------------------------------------------------------
  # * Name      : Average
  #   Info      : Returns average of party's stats, based on parameter
  #   Author    : Kain Nobel
  #   Call Info : Parameter is a string representing parameter in question
  #               Float will return the average as a float (Optional)
  #-----------------------------------------------------------------------------
  def average(stat, float = false)
    return 0 if @actors.size == 0
    avg   = float ? 0.0 : 0
    case stat.downcase!
    when 'hp'    ; @actors.each_index {|i| avg += @actors[i].hp}
    when 'maxhp' ; @actors.each_index {|i| avg += @actors[i].maxhp}
    when 'sp'    ; @actors.each_index {|i| avg += @actors[i].sp}
    when 'maxsp' ; @actors.each_index {|i| avg += @actors[i].maxsp}
    when 'level' ; @actors.each_index {|i| avg += @actors[i].level}
    when 'exp'   ; @actors.each_index {|i| avg += @actors[i].exp}
    when 'str'   ; @actors.each_index {|i| avg += @actors[i].str}
    when 'dex'   ; @actors.each_index {|i| avg += @actors[i].dex}
    when 'agi'   ; @actors.each_index {|i| avg += @actors[i].agi}
    when 'int'   ; @actors.each_index {|i| avg += @actors[i].int}
    when 'atk'   ; @actors.each_index {|i| avg += @actors[i].atk}
    when 'pdef'  ; @actors.each_index {|i| avg += @actors[i].pdef}
    when 'mdef'  ; @actors.each_index {|i| avg += @actors[i].mdef}
    when 'eva'   ; @actors.each_index {|i| avg += @actors[i].eva}
    end
    return avg / @actors.size
  end
  #-----------------------------------------------------------------------------
  # * Name      : Gain All
  #   Info      : Gain all items (depending on type)
  #   Author    : Kain Nobel
  #   Call Info : Type is the type of 'item' to gain
  #                 -1 : All Items, Weapons, Armors
  #                  0 : All Items
  #                  1 : All Weapons
  #                  2 : All Armors
  #               Quantity is an integer from 1 to 99 (Optional)
  #-----------------------------------------------------------------------------
  def gain_all(type, quantity = 99)
    if type.is_a?(Fixnum) && type.between?(-1, 2)
      case type
      when -1
        $data_items.each_index    {|i| gain_item(i, quantity.abs)}
        $data_weapons.each_index  {|i| gain_weapon(i, quantity.abs)}
        $data_armors.each_index   {|i| gain_armor(i, quantity.abs)}
      when 0 ; $data_items.each_index   {|i| gain_item(i, quantity.abs)}
      when 1 ; $data_weapons.each_index {|i| gain_weapon(i, quantity.abs)}
      when 2 ; $data_armors.each_index  {|i| gain_armor(i, quantity.abs)}
      end
    end
  end
  #-----------------------------------------------------------------------------
  # * Name      : Lose All
  #   Info      : Lose all items (depending on type)
  #   Author    : Kain Nobel
  #   Call Info : Type is the type of 'item' to lose
  #                 -1 : All Items, Weapons, Armors
  #                  0 : All Items
  #                  1 : All Weapons
  #                  2 : All Armors
  #               Quantity is an integer from 1 to 99 (Optional)
  #-----------------------------------------------------------------------------
  def lose_all(type, quantity = 99)
    quantity = -quantity.abs if quantity > 0
    gain_all(type, quantity)
  end
end
Expand to see the code.


'RGSS.RTP' Spoiler
#===============================================================================
# ** RGSS.RTP
#-------------------------------------------------------------------------------
# Written by  : Kain Nobel
# Version     : 1.0
# Last Update : 08/19/2008
# Created On  : 08/16/2008
#-------------------------------------------------------------------------------
# * Description :
#
#   This script reads the GameINI and the Window's Registry to return the data
#   information of the Run Time Package(s) the game has assigned. You can list
#   files from a single RTP, or all RTP files, with ease.
#-------------------------------------------------------------------------------
# * Requirements :
#
#   This script requires the Aleworks Library to read the Window's Registry.
#   You can find what you need by visiting this topic
#
#   - http://www.hbgames.org/forums/index.php?topic=28392.0
#-------------------------------------------------------------------------------
# * Instructions :
#
#   Place The Script Below the SDK and Above Main.
#===============================================================================

MACL::Loaded << 'RGSS.RTP'

#===============================================================================
# ** GameINI
#-------------------------------------------------------------------------------
#   This module simply reads Game.ini file located in the parent Game folder.
#===============================================================================

module GameINI
  def self.read(entry)
    File.open("Game.ini").each{ |row|
    if row =~ Regexp.new("^" + entry + "=.*$")
      str = (row.scan(Regexp.new("^" + entry + "=(.*)$"))[0]).to_s
      return str == "" ? '(none)' : str
    end
    }
    File.close("Game.ini")
  end
end

#===============================================================================
# ** RTP
#-------------------------------------------------------------------------------
#   This class simply sets up RTP information for use in other scripts.
#===============================================================================

module RTP
  #-----------------------------------------------------------------------------
  # * Public Instance Variables
  #-----------------------------------------------------------------------------
  attr_reader :files
  #-----------------------------------------------------------------------------
  # * RTP.files(n)
  #-----------------------------------------------------------------------------
  def RTP.files(n = 1)
    requirement_test
    return if !n.is_a?(Numeric)
    filepaths = []
    n = n.to_s unless n.is_a?(String)
    key = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Enterbrain\\RGSS\\RTP\\'
    data = Aleworks::Registry.read_entry(key, GameINI.read('RTP'+n))
    data.gsub!('\\', '/') unless data.nil?
    return data
  end
  #-----------------------------------------------------------------------------
  # * RTP.list_all(directory)
  #-----------------------------------------------------------------------------
  def RTP.list(directory)
    requirement_test
    return if !directory.is_a?(String)
    files = Dir.new(directory).entries
    files[0,2] = nil, nil
    for i in 1...3
      unless RTP.files(i).nil?
        dir = Dir.new(RTP.files(i)+directory).entries
        dir[0,2] = nil, nil
        files += dir
      end
    end
    files.compact!
  end
  #-----------------------------------------------------------------------------
  # * RTP.requirement_test
  #-----------------------------------------------------------------------------
  def RTP.requirement_test
    unless defined?(Aleworks) && Aleworks.is_a?(Module)
      print("Please install the Aleworks Library to read the Windows Registry,",
      "you can find it @\n http://www.hbgames.org/forums/index.php?topic=28392.0")
      exit
    end
  end
end
Expand to see the code.


^^As basic as this is, and even though this requires Aleworks libraries to read the Windows Registry, this module has came in useful to me for a couple times, bust mostly listing RTP Audio files. To sum it all up, it reads files from both the Game directory, and its assigned RTP directories (and sub-directories) and can return a list of files 'n stuff.

Although this module is small at the moment, I will be expanding this for the future RTP File Manager (if I ever get around to doing it), which will be used for pre-launch of games who use seperate RTPs which cuts/copies your graphics and audio into your game folder if it has been logged. (Please note, this doesn't do that yet, this is just something I've been thinking about for awhile.)

If you need, I'll add the proper heading for the 'RGSS.RTP' module methods tomorrow, and explain what they do so far, which isn't a whole lot yet.
Ok. I am actually wanting to work on an API module. I am actually going to request Aleworks on adding his library to the MACL.
I'm intrigued. What do you mean by API module?
A single module what holds all the API declaration, vs. putting a bunch of API into modules. This will prevent multiple scripts creating and using the same API, creating multiple objects.

module API
  Function_Name = WinAPI.new(.....)
  Funciton_Name = WinAPI.new(...)
end
Expand to see the code.


I actually had a code, that generated this automatically, reading all the win32 api functions, but it ended up as one big ass code. I need to dig that up again.
Found it. Rpgmaker did the code, I modified it to a module and added the instance variable, so it wouldnt create API objects over and over again.

http://www.owainc.net/scripts/win32_api.txt
Oh. By API you meant Win32API. Eh. Pretty neat stuff though.
I don't know how much of that to include because there are so many dll/dll functions in there. I kinda want to just include it all (better to have too much that too little, as the Compiler I am working will remove un-needed parts anyways). But if I do include it all (I probably will unless someone has a better suggestion), I will divide each dll into it's own module

module API
  module Digest
    # functions
  end
  module User32
    # functions
  end
end
Expand to see the code.


That should make calling and organization easier.
API::User32.MessageBox(0, 'Message', 'Title', 0)
Expand to see the code.


A little simpler than
api = Win32API.new('user32', 'MessageBox', ['L', 'P', 'P', 'L'], 'I')
api.call(0, 'Message', 'Title', 0)
Expand to see the code.
Yeah, most likely. Also, is there a list of missing stuff from the MACL? I've got a couple of utility things that could be of use, like a Collections module (queues, deques, stacks, lists, etc.), a Sort module (quicksort, heapsort, shellsort, etc.) and a bunch of Geometry classes that could be modularized (Geometry, Geometry::Point, Geometry::Polygon, Geometry::Ellipse, etc.).

We could also include a Physics module to calculate stuff like projectile arcs, velocity, free falls, etc.
Post 'em and I'll add them. I plan to add a lot of Math modules when I have time to code them.
I'm guessing I'm probably the only person that has utilized 'Modules.Event_Spawner' thus far, but it is a really great concept yet needs alot of other things debugged from it, that and 'RGSS.Map', because RGSS gives me so much crap about deleting events and changing maps and spawning events and the such. I've prettymuch had to start my own SDK portions for it, and alias my private 'SDK' method splits later on and check if 'event.nil?' everywhere I go in the editor that has to do with events.

I know this isn't the SDK topic, but since this has to do with the SDK-ish method splits I've had to do to overcome problems, I'll already tell you some of the stuff I had to split and alias just to use these two systems together, just because I don't want to overwrite everything...

Game_Map
  #passable?
    -events_passable?(event, x, y, self_event, bit)
    -tiles_passable?(tile_id, x, y, bit)

Interpeter
  #setup_starting_event
    -setup_starting_event_refresh
    -setup_starting_event_common_reserve
    -setup_starting_event_map(event)
    -setup_starting_event_common(common_event)

I've also had to alias Sprite_Character#update (unless @character.nil? ; rgss_map_sprite_char_update ; end) since updating a nil @character pops error as well.

Yet, I still get errors in other event-related places, because of nil events, which really sucks because I want to use both of these together without having to worry about the nil event errors. If it isn't a total loss, I'd still like to use 'RGSS.Map' and 'Event_Spawner' together in future scripts, even if I have to SDK-ize everything to prevent overwritting (and to prevent saving a bunch of spawned events and using a bunch of self switches). So, let me know if you're going to fix everything or if you would like my help, or if I should just do everything myself and try 'n fix it.

I guess there could be other work arounds, but since its all your origional work I figured I should share all this with you, and I'll post everything I've done which has resolved some issues so far if you would like me to, but like I said some of it involves its own SDK type splits just to overcome unless you want to start overwritting stuff...

I donno, unless you've got your own way you want to overcome these issues, its definately something you'll really have to sit down and tinker with! I hope to still be able to use it in the future without worry of game-crashing bugs (like NilClass errors with deleted events).
The next SDK will have the Sprite_Character#update method split up.

The passable? method diffently needs split up. I'll look into the setup_starting_event as well.

If you find any errors with anything in the SDK/MACL, let me know, and I'll fix 'em.
http://www.owainc.net/scripts/modules.api.txt


Ok. That's what I have done with API so far. Right now, I have it divided into 7 different parts to keep it under 10,000 lines. Which means the API addition alone is about 4 times larger than the rest of the MACL. :p

#==============================================================================
# ** API
#==============================================================================

module API
  #-------------------------------------------------------------------------
  # * Name      : Current API Module Version
  #   Author    : SephirothSpawn
  #   Call Info : API Arguments, Function Arguments
  #-------------------------------------------------------------------------
  def self.call(api_arguments, function_arguments)
    # Gets instance name
    instance_name = "@#{api_arguments[1]}"
    # Gets instance variable
    instance = eval instance_name
    # If nil instance variable
    if instance.nil?
      p 'create'
      # Create instance variable
      eval "#{instance_name} = Win32API.new(*api_arguments)"
    end
    # Get instance variable
    instance = eval instance_name
    # Call Instance
    instance.call(*function_arguments)
  end
end
Expand to see the code.


All the instances will be created in the base API module, and every other sub-module just calls the method with the parameters involved. That cut down the
if @instance.nil?
  @instance =
end
@instance.call
Expand to see the code.


Down to
API.call(api_arguments, function_arguments)
Expand to see the code.


A little bit shorter when there are I believe 6140-6150 methods.

The list is organized by API name, and each method is organized by function name, in alphabetical order.
Pretty neat. All that's missing now is a builder. Actually, we should probably do a web builder for the MACL (along with the API), a la Mootools or something.

You go on a given page, select the sections you want, and you download the generated file which contains only the sections you wanted. That'd be kinda cool.

I could do it if you want.
If you are talking about adding methods and such to the macl, I was working on something that did this, but my php skills are horrible (was nothing more than directory/file reading, no Mysql). Once I learn some mysql, I plan to make something where people can add methods/classes/modules to the MACL and someone can approve the modification and it auto-updates the MACL. Users can download the current MACL into a single text file. This prevents taking such a great deal of my time to update the MACL. Hopefully by next release I will have enough MySQL experience where I can do such a thing.

This, combined with the Compiler I am still working on should save a lot of time.

I am hoping to have the new MACL by friday. I am merging the Keyboard and Mouse module and adding them to the Input module (Still keeping the Keyboard/Mouse Module in the MACL for scripts that require it). I am adding a lot of new modules/systems as well.
No, I was thinking more about a "build your own MACL" script, which would allow people to select diverse modules and it'd generate their MACL.rb or MACL.rxdata file with only the selected scripts and nothing else.
That actually wouldn't be too hard to generate, especially since it will basically require files much like the compiler. The difference is the compiler just does that automatically, adding parts scripts require. I'll try to finish at least a demo of the compiler by tomorrow so you can see it in action. But I like the idea of the build your own MACL as well. It wouldn't take much scene work to make the addition.
I was thinking of putting it on the web though, but I guess you could make a scene out of it :o
Why not both? XD I am not sure how you plan on doing it, but I plan on dividing directories for each part

- Ruby
--Higher Classes
---Object
----subclasses.txt
---Module
----attr_sec_accessor.txt
----attr_sec_reader.txt
etc.

As well as adding something so when you include something like attr_sec_accessor which requires attr_sec_reader, it automatically adds that to the include list.
I don't know WtF I was talking about the other night, with overwritting SDK check_reqs method to do both, but each MACL section should be SDK logged.

if Object.const_defined?(:SDK)
  SDK.log('MACL::RGSS.Whatever', 'MACL Authors', 2.4, '06-06-06')
end

MACL::Loaded << 'RGSS.Whatever'
Expand to see the code.


Would you be able to put the Plane_ScrollStates system into the MACL, and make it independant from the way you did it for the Default Menu/Battle in your test bed? That script is pretty bad ass, I want to be able to draw a scroll_state anywhere. This, I had attempted to do, but I can't seem to manip the drawing coord to match where normal draw_actor_states would wind up no matter what I change it to. I wanted to be able to use it independantly for my CMS, but its really not liking me.

Window.ScrollStatus' attempt Spoiler
#===============================================================================
# ~** Window Scroll States **~
#-------------------------------------------------------------------------------
# Written by  : Kain Nobel (originated from SephirothSpawn)
# Version     : 0.0
# Last Update : 09.08.2008
#-------------------------------------------------------------------------------
# * Description :
#
#   This script allows you to use Plane_ScrollStatus in any window with the
#   draw_actor_state() method, because it is defined in Window_Base.
#===============================================================================
#-------------------------------------------------------------------------------
# * SDK Log
#-------------------------------------------------------------------------------
SDK.log('Window.ScrollStates', 'Kain Nobel', 0.0, '09.08.2008')
SDK.disable('Window.ScrollStates')
#-------------------------------------------------------------------------------
# * SDK Enabled Log - BEGIN
#-------------------------------------------------------------------------------
if SDK.enabled?('Window.ScrollStates') && defined?(MACL) && MACL.is_a?(Module)
#===============================================================================
# ** Plane_ScrollStatus
#-------------------------------------------------------------------------------
#   This is an object scrolls the status display seamlessly.
#===============================================================================
class Plane_ScrollStatus < Plane
  #--------------------------------------------------------------------------
  # * Show Icons When Avialable
  #--------------------------------------------------------------------------
  Show_Icons = true
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :actor
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(actor_index, x, y, w, h, z = 105)
    v = Viewport.new(x, y, w, h)
    v.z = z
    super(v)
    if actor_index.is_a?(Numeric) ; @actor = $game_party.actors[actor_index]
    else                          ; @actor = actor_index
    end
    update
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    unless @states == @actor.states
      @states = @actor.states.dup
      unless self.bitmap.nil?
        self.bitmap.dispose
        self.bitmap = nil
      end
      s_names, i_names = [], []
      for i in @states
        if Show_Icons && $data_states[i].icon != nil
          s_names << nil
          i_names << $data_states[i].icon_name
          next
        end
        s_names << $data_states[i].name
      end
       if s_names.empty?
        if Show_Icons && RPG::State.normal_icon != nil
          s_names << nil
          i_names << RPG::State::Normal_Icon
        else
          s_names << 'Normal'
        end
      end
      has_icons = i_names.size > 0
      string = Show_Icons && has_icons ? '' : '['
      for s in s_names
        if s.nil?
          string += " [#{i_names.shift}]"
          next
        end
        string += " #{s}"
      end
      string += ' ]' unless Show_Icons && has_icons
      if Show_Icons && has_icons
        text, icons = Bitmap.string_to_text_icons(string)
        ox = Bitmap.icon_text_sizes(text, icons)[3]
      else ; ox = Bitmap.text_size(string).width
      end
      bitmap = Bitmap.new(ox + self.viewport.rect.width, 32)
      if Show_Icons && has_icons
        bitmap.draw_icon_text(0, 0, ox, 32, string)
      else
        bitmap.draw_text(0, 0, ox, 32, string)
      end
      self.bitmap = bitmap
    end
    self.ox += 1
  end
end
#===============================================================================
# ** Window_Base
#-------------------------------------------------------------------------------
#   This superclasses' normal methods have been enhanced to handle the Scroll
# Status display.
#===============================================================================
class Window_Base < Window
  #-----------------------------------------------------------------------------
  # * Alias Listings
  #-----------------------------------------------------------------------------
  alias_method :scroll_states_window_base_update,   :update
  alias_method :scroll_states_window_base_dispose,  :dispose
  alias_method :scroll_states_draw_actor_state,     :draw_actor_state
  #-----------------------------------------------------------------------------
  # * Update
  #-----------------------------------------------------------------------------
  def update
    unless @scroll_states.nil?
      @scroll_states.each {|state| state.update}
    end
    scroll_states_window_base_update
  end
  #-----------------------------------------------------------------------------
  # * Dispose
  #-----------------------------------------------------------------------------
  def dispose
    unless @scroll_states.nil?
      @scroll_states.each {|state| state.dispose}
    end
    scroll_states_window_base_dispose
  end
  #-----------------------------------------------------------------------------
  # * Draw Actor State
  #-----------------------------------------------------------------------------
  def draw_actor_state(actor, x, y, width = 128, height = 32, z = 105)
    if defined?(Plane_ScrollStatus)
      @scroll_states = []
      @scroll_states << Plane_ScrollStatus.new(actor, x, y, width, height, z)
    else ; scroll_states_draw_actor_state(actor, x, y)
    end
  end
end
#-------------------------------------------------------------------------------
# * SDK Enabled Test - END
#-------------------------------------------------------------------------------
end
Expand to see the code.
I suppose I could add the scroll status thing.

I don't know about the SDK logging. As I said above, you can just use:
if MACL.loaded('Part')
Expand to see the code.

Logging it just seems rather redundant.

Tip: When you modify someone's work, put their name as the author, your name as the modifier. ;)
That API module is rather eloquent, as I've come to expect from you Seph.  Good job!

I was wondering, about having a Data module instead of $data_ variables (it's probably a stupid idea).  Does anybody know what the Data class is?  Apparently it's already defined in RGSS, as I get a "Data is not a module" error when writing "module Data".
Thank you.

p Object.constants.sort

class Data
  p self.constants, self.private_methods - Object.private_methods, self.public_methods - Object.public_methods
end
Expand to see the code.


I tested this above all the other scripts. Apparently the last Data does exist, but has no constants, private_methods or public methods (I removed the methods from the object class and got an empty array).

I have no idea what this class is for.


What did you mean make $data_classes into a module?

Also, check this out if you haven't seen it:
#==============================================================================
# ** Modules.Game_Data (1.0)                                  By SephirothSpawn
#------------------------------------------------------------------------------
# * Description :
#
#   This modules lets you add new $game_data objects to your game with a simple
#   call script within your script.
#------------------------------------------------------------------------------
# * Syntax :
#
#   Adding new $game_data object
#    - Game_Data.add_game_data('variable_name', 'Class_Name')
#
#   Example : Adding new Game_Database to your $game datas.
#
#    - Game_Data.add_game_data('$game_database', 'Game_Database')
#==============================================================================

MACL::Loaded << 'Modules.Game_Data'

#==============================================================================
# ** Game_Data
#==============================================================================

module Game_Data
  #--------------------------------------------------------------------------
  # * Instance Variable Setup
  #--------------------------------------------------------------------------
  @additions = []
  @variable_names = []
  #--------------------------------------------------------------------------
  # * Additions
  #--------------------------------------------------------------------------
  def self.additions
    return @additions
  end
  #--------------------------------------------------------------------------
  # * Add Game Data
  #--------------------------------------------------------------------------
  def self.add_game_data(global_variable_name, game_object_class)
    # If Variable Name Used
    if @variable_names.include?(global_variable_name)
      # Print Error
      p global_variable_name + ' already used. Please use a different ' +
        'variable name.'
      return
    end
    # Add Addition
    @additions << [global_variable_name, game_object_class]
  end
end

#==============================================================================
# ** Scene_Title
#==============================================================================

class Scene_Title
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_macladdgamedata_scnttl_cng, :command_new_game
  #--------------------------------------------------------------------------
  # * Command: New Game
  #--------------------------------------------------------------------------
  def command_new_game
    # Original Command: New Game
    seph_macladdgamedata_scnttl_cng
    # Pass Through Game Data List
    Game_Data.additions.each {|vg| eval "#{vg[0]} = #{vg[1]}.new"}
  end
end

#==============================================================================
# ** Scene_Save
#==============================================================================

class Scene_Save
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_macladdgamedata_scnsv_wsd, :write_save_data
  #--------------------------------------------------------------------------
  # * Write Save Data
  #--------------------------------------------------------------------------
  def write_save_data(file)
    # Original Write Save Data
    seph_macladdgamedata_scnsv_wsd(file)
    # Pass Through Game Data List
    Game_Data.additions.each {|vg| eval "Marshal.dump(#{vg[0]}, file)"}
  end
end

#==============================================================================
# ** Scene_Load
#==============================================================================

class Scene_Load
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_macladdgamedata_scnld_rsd, :read_save_data
  #--------------------------------------------------------------------------
  # * Read Save Data
  #--------------------------------------------------------------------------
  def read_save_data(file)
    # Original Read Save Data
    seph_macladdgamedata_scnld_rsd(file)
    # Pass Through Game Data List
    Game_Data.additions.each {|vg| eval "#{vg[0]} = Marshal.load(file)"}
  end
end
Expand to see the code.


This is actually in the current MACL, just not sure if anyone has seen it (and since we are on the discussion of data).

No more aliasing Scene_Title, Scene_Save and Scene_Load, just a simple single line code and it does it all for us.

Although I am going to modify this so:

In Scene_Title, some game objects will be created before the original command_new_game, others after. They will also check for a ":setup" method and run it if the method is defined.

Scene_Save, data saved before or after original call.

Scene_Load, data loaded before or after original call. It will also check for a ":load" method here and call it if it is found. Might be overkill, but I want to make it completely possible for anyone to add a new game object with only 1 line of code.
Having a Data module would be pretty much useless and would only add overhead whenever using the global variables. I mean...they're global anyway!

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=9417