Class: Game_Variables

Inherits:
Array show all
Defined in:
scripts/00600 Script_RMXP/00100 Event_Living_Data.rb

Overview

Class that describe game variables

Instance Method Summary collapse

Constructor Details

#initializeGame_Variables

default initialization of game variables



53
54
55
56
57
58
59
# File 'scripts/00600 Script_RMXP/00100 Event_Living_Data.rb', line 53

def initialize
  if $data_system
    super($data_system.variables.size, 0)
  else
    super(200, 0)
  end
end

Instance Method Details

#[](index)

Note:

return 0 if the variable is outside of the array.

Getter

Parameters:

  • index (Integer)

    the index of the variable



64
65
66
67
68
# File 'scripts/00600 Script_RMXP/00100 Event_Living_Data.rb', line 64

def [](index)
  return 0 if size <= index

  super(index)
end

#[]=(index, value)

Setter

Parameters:

  • index (Integer)

    the index of the variable in the Array

  • value (Integer)

    the new value of the variable



73
74
75
76
77
78
79
80
# File 'scripts/00600 Script_RMXP/00100 Event_Living_Data.rb', line 73

def []=(index, value)
  unless value.is_a?(Integer)
    raise TypeError, "Unexpected #{value.class} value. $game_variables store numbers and nothing else, use $option to store anything else."
  end

  super(size, 0) while size < index
  super(index, value)
end