Home > RGSS Script Reference > Game_Switches
Game_Switches
Inherits from: None
Description: This class holds the game switches and has methods for assigning and getting data from switches.
class Game_Switches
# ------------------------------------
def initialize
@data = []
end
# ------------------------------------
def [](switch_id)
if switch_id <= 5000 and @data[switch_id] != nil
return @data[switch_id]
else
return false
end
end
# ------------------------------------
def []=(switch_id, value)
if switch_id <= 5000
@data[switch_id] = value
end
end
end
|
Data: The array of game switches. Contains 5000 boolean variables.
Initialize
Arguments: None
Local Variables: None
How it Works: Initializes the switch array to an empty array.
[]
Arguments:
Switch_ID: The array index of the switch to return.
Local Variables: None
How it Works: This method returns the current value associated with the switch ID passed to it. If the value is 5000 or less and isn't
nil, the current value of the switch is returned. Otherwise, the method returns false because a value hasn't been assigned to the switch yet.
[]=
Arguments:
Switch_ID: The array index of the switch to set.
Value: A boolean representing the value to assign to that switch.
Local Variables: None
How it Works: This method set the current value associated with the switch ID passed to it to the value passed to the method. If the value is 5000 or less, the switch is set to that value. Otherwise, the method does nothing because the switch ID isn't valid.
|
|