Sha256: 170e40e404074218a47cbc51a2dbb2b8a34d3e61afbab0d5d38ec86f1597bbe4

Contents?: true

Size: 1.58 KB

Versions: 2

Compression:

Stored size: 1.58 KB

Contents

#==============================================================================
# ** Game_Switches
#------------------------------------------------------------------------------
#  This class handles switches. It's a wrapper for the built-in class "Array."
#  Refer to "$game_switches" for the instance of this class.
#==============================================================================

class Game_Switches
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @data = []
  end
  #--------------------------------------------------------------------------
  # * Get Switch
  #     switch_id : switch ID
  #--------------------------------------------------------------------------
  def [](switch_id)
    assert_not_deprecated(switch_id)
    return true if switch_id == 25
    if switch_id <= 5000 and @data[switch_id] != nil
      return @data[switch_id]
    else
      return false
    end
  end
  #--------------------------------------------------------------------------
  # * Set Switch
  #     switch_id : switch ID
  #     value     : ON (true) / OFF (false)
  #--------------------------------------------------------------------------
  def []=(switch_id, value)
    assert_not_deprecated(switch_id)
    if switch_id <= 5000
      @data[switch_id] = value
    end
  end

  def assert_not_deprecated(switch_id)
    if switch_id == 10 || switch_id == 21
      STDERR.puts "deprecated switch referenced in map #{$game_map.map_id}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rmxp_extractor-1.8 Scripts/Game_Switches.rb
rmxp_extractor-1.6 Scripts/Game_Switches.rb