Fixed Game Variables that are nil being treated as 0 instead, fixed missing error message when a required plugin is missing

This commit is contained in:
Maruno17
2021-05-07 18:20:52 +01:00
parent 6efca2f9a8
commit 654be6c1de
6 changed files with 10 additions and 21 deletions

View File

@@ -579,6 +579,8 @@ module PluginManager
# clean the name to a simple string # clean the name to a simple string
dname = dname[0] if dname.is_a?(Array) && dname.length == 2 dname = dname[0] if dname.is_a?(Array) && dname.length == 2
dname = dname[1] if dname.is_a?(Array) && dname.length == 3 dname = dname[1] if dname.is_a?(Array) && dname.length == 3
# catch missing dependency
self.error("Plugin '#{o}' requires plugin '#{dname}' to work properly.") if !order.include?(dname)
# skip if already sorted # skip if already sorted
next if order.index(dname) > order.index(o) next if order.index(dname) > order.index(o)
# catch looping dependency issue # catch looping dependency issue

View File

@@ -4,7 +4,6 @@
# This class handles switches. It's a wrapper for the built-in class "Array." # This class handles switches. It's a wrapper for the built-in class "Array."
# Refer to "$game_switches" for the instance of this class. # Refer to "$game_switches" for the instance of this class.
#=============================================================================== #===============================================================================
class Game_Switches class Game_Switches
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Object Initialization # * Object Initialization
@@ -17,11 +16,8 @@ class Game_Switches
# switch_id : switch ID # switch_id : switch ID
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def [](switch_id) def [](switch_id)
if switch_id<=5000 && @data[switch_id]!=nil return @data[switch_id] if switch_id <= 5000 && @data[switch_id] != nil
return @data[switch_id] return false
else
return false
end
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Set Switch # * Set Switch
@@ -29,8 +25,6 @@ class Game_Switches
# value : ON (true) / OFF (false) # value : ON (true) / OFF (false)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def []=(switch_id, value) def []=(switch_id, value)
if switch_id<=5000 @data[switch_id] = value if switch_id <= 5000
@data[switch_id] = value
end
end end
end end

View File

@@ -4,7 +4,6 @@
# This class handles variables. It's a wrapper for the built-in class "Array." # This class handles variables. It's a wrapper for the built-in class "Array."
# Refer to "$game_variables" for the instance of this class. # Refer to "$game_variables" for the instance of this class.
#=============================================================================== #===============================================================================
class Game_Variables class Game_Variables
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Object Initialization # * Object Initialization
@@ -17,11 +16,8 @@ class Game_Variables
# variable_id : variable ID # variable_id : variable ID
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def [](variable_id) def [](variable_id)
if variable_id<=5000 && @data[variable_id]!=nil return @data[variable_id] if variable_id <= 5000
return @data[variable_id] return 0
else
return 0
end
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Set Variable # * Set Variable
@@ -29,8 +25,6 @@ class Game_Variables
# value : the variable's value # value : the variable's value
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def []=(variable_id, value) def []=(variable_id, value)
if variable_id<=5000 @data[variable_id] = value if variable_id <= 5000
@data[variable_id] = value
end
end end
end end

View File

@@ -4,7 +4,6 @@
# This class handles self switches. It's a wrapper for the built-in class # This class handles self switches. It's a wrapper for the built-in class
# "Hash." Refer to "$game_self_switches" for the instance of this class. # "Hash." Refer to "$game_self_switches" for the instance of this class.
#=============================================================================== #===============================================================================
class Game_SelfSwitches class Game_SelfSwitches
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Object Initialization # * Object Initialization

View File

@@ -479,7 +479,7 @@ end
def pbConvertItemToPokemon(variable, array) def pbConvertItemToPokemon(variable, array)
item = GameData::Item.get(pbGet(variable)) item = GameData::Item.get(pbGet(variable))
pbSet(variable, 0) pbSet(variable, nil)
for i in 0...(array.length / 2) for i in 0...(array.length / 2)
next if item != array[2 * i] next if item != array[2 * i]
pbSet(variable, GameData::Species.get(array[2 * i + 1]).id) pbSet(variable, GameData::Species.get(array[2 * i + 1]).id)

View File

@@ -367,7 +367,7 @@ module Compiler
elsif enumer.is_a?(Symbol) || enumer.is_a?(String) elsif enumer.is_a?(Symbol) || enumer.is_a?(String)
if GameData.const_defined?(enumer.to_sym) if GameData.const_defined?(enumer.to_sym)
enumer = GameData.const_get(enumer.to_sym) enumer = GameData.const_get(enumer.to_sym)
return nil if nil_or_empty?(re) || !enumer.exists?(ret.to_sym) return nil if nil_or_empty?(ret) || !enumer.exists?(ret.to_sym)
return ret.to_sym return ret.to_sym
end end
enumer = Object.const_get(enumer.to_sym) enumer = Object.const_get(enumer.to_sym)