diff --git a/Data/Scripts/001_Technical/001_MKXP_Compatibility.rb b/Data/Scripts/001_Technical/001_MKXP_Compatibility.rb index 95def1efd..4a388229d 100644 --- a/Data/Scripts/001_Technical/001_MKXP_Compatibility.rb +++ b/Data/Scripts/001_Technical/001_MKXP_Compatibility.rb @@ -1,4 +1,4 @@ -# Using mkxp-z v2.1.1 - https://gitlab.com/mkxp-z/mkxp-z/-/releases/v2.1.1 +# Using mkxp-z v2.1.2 - https://gitlab.com/mkxp-z/mkxp-z/-/releases/v2.1.2 $VERBOSE = nil Font.default_shadow = false if Font.respond_to?(:default_shadow) Graphics.frame_rate = 40 diff --git a/Data/Scripts/001_Technical/002_Files/001_FileTests.rb b/Data/Scripts/001_Technical/002_Files/001_FileTests.rb index 938e3ef3c..5355a80aa 100644 --- a/Data/Scripts/001_Technical/002_Files/001_FileTests.rb +++ b/Data/Scripts/001_Technical/002_Files/001_FileTests.rb @@ -181,7 +181,7 @@ module RTP @rtpPaths = nil def self.exists?(filename,extensions=[]) - return false if !filename || filename=="" + return false if nil_or_empty?(filename) eachPathFor(filename) { |path| return true if safeExists?(path) for ext in extensions @@ -200,7 +200,7 @@ module RTP end def self.getPath(filename,extensions=[]) - return filename if !filename || filename=="" + return filename if nil_or_empty?(filename) eachPathFor(filename) { |path| return path if safeExists?(path) for ext in extensions diff --git a/Data/Scripts/001_Technical/003_Intl_Messages.rb b/Data/Scripts/001_Technical/003_Intl_Messages.rb index bcc5a2ace..7aec32454 100644 --- a/Data/Scripts/001_Technical/003_Intl_Messages.rb +++ b/Data/Scripts/001_Technical/003_Intl_Messages.rb @@ -405,7 +405,7 @@ class Messages if msgs.is_a?(Array) f.write("[#{secname}]\r\n") for j in 0...msgs.length - next if msgs[j]==nil || msgs[j]=="" + next if nil_or_empty?(msgs[j]) value=Messages.normalizeValue(msgs[j]) origValue="" if origMessages @@ -421,7 +421,7 @@ class Messages f.write("[#{secname}]\r\n") keys=msgs.keys for key in keys - next if msgs[key]==nil || msgs[key]=="" + next if nil_or_empty?(msgs[key]) value=Messages.normalizeValue(msgs[key]) valkey=Messages.normalizeValue(key) # key is already serialized diff --git a/Data/Scripts/001_Technical/005_PluginManager.rb b/Data/Scripts/001_Technical/005_PluginManager.rb index 17b22af18..4c7a6771b 100644 --- a/Data/Scripts/001_Technical/005_PluginManager.rb +++ b/Data/Scripts/001_Technical/005_PluginManager.rb @@ -438,7 +438,7 @@ module PluginManager message += "#{$!.class} occurred.\r\n" # go through message content for line in $!.message.split("\r\n") - next if !line || line == "" + next if nil_or_empty?(line) n = line[/\d+/] err = line.split(":")[-1].strip lms = line.split(":")[0].strip diff --git a/Data/Scripts/004_Game classes/009_Game_Player.rb b/Data/Scripts/004_Game classes/009_Game_Player.rb index ab8b993e2..9e8e9f751 100644 --- a/Data/Scripts/004_Game classes/009_Game_Player.rb +++ b/Data/Scripts/004_Game classes/009_Game_Player.rb @@ -423,7 +423,7 @@ def pbGetPlayerCharset(meta,charset,trainer=nil,force=false) end $game_player.charsetData = [$Trainer.character_ID,charset,outfit] if $game_player ret = meta[charset] - ret = meta[1] if !ret || ret=="" + ret = meta[1] if nil_or_empty?(ret) if pbResolveBitmap("Graphics/Characters/"+ret+"_"+outfit.to_s) ret = ret+"_"+outfit.to_s end diff --git a/Data/Scripts/007_Objects and windows/002_MessageConfig.rb b/Data/Scripts/007_Objects and windows/002_MessageConfig.rb index 80895bd44..a26a7aae0 100644 --- a/Data/Scripts/007_Objects and windows/002_MessageConfig.rb +++ b/Data/Scripts/007_Objects and windows/002_MessageConfig.rb @@ -81,15 +81,15 @@ module MessageConfig if skin && skin!="" skin=pbResolveBitmap("Graphics/Windowskins/"+skin) || "" end - skin=pbResolveBitmap("Graphics/System/Window") if !skin || skin=="" - skin=pbResolveBitmap("Graphics/Windowskins/001-Blue01") if !skin || skin=="" + skin=pbResolveBitmap("Graphics/System/Window") if nil_or_empty?(skin) + skin=pbResolveBitmap("Graphics/Windowskins/001-Blue01") if nil_or_empty?(skin) return skin || "" end def self.pbGetSystemFrame if !@@systemFrame skin=MessageConfig.pbDefaultSystemFrame - skin=MessageConfig.pbDefaultWindowskin if !skin || skin=="" + skin=MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin) @@systemFrame=skin || "" end return @@systemFrame @@ -98,7 +98,7 @@ module MessageConfig def self.pbGetSpeechFrame if !@@defaultTextSkin skin=MessageConfig.pbDefaultSpeechFrame - skin=MessageConfig.pbDefaultWindowskin if !skin || skin=="" + skin=MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin) @@defaultTextSkin=skin || "" end return @@defaultTextSkin diff --git a/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb b/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb index 3a4ac911d..0188cd94e 100644 --- a/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb +++ b/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb @@ -868,7 +868,7 @@ class SpriteWindow_Base < SpriteWindow @customskin.dispose if @customskin @customskin=nil resolvedName=pbResolveBitmap(skin) - return if !resolvedName || resolvedName=="" + return if nil_or_empty?(resolvedName) @customskin=AnimatedBitmap.new(resolvedName) RPG::Cache.retain(resolvedName) __setWindowskin(@customskin.bitmap) diff --git a/Data/Scripts/010_Data/002_PBS data/008_Species.rb b/Data/Scripts/010_Data/002_PBS data/008_Species.rb index 303203e41..31add0436 100644 --- a/Data/Scripts/010_Data/002_PBS data/008_Species.rb +++ b/Data/Scripts/010_Data/002_PBS data/008_Species.rb @@ -164,7 +164,7 @@ module GameData @height = hash[:height] || 1 @weight = hash[:weight] || 1 @color = hash[:color] || :Red - @shape = hash[:shape] || :Body + @shape = hash[:shape] || :Head @habitat = hash[:habitat] || :None @generation = hash[:generation] || 0 @mega_stone = hash[:mega_stone] diff --git a/Data/Scripts/010_Data/002_PBS data/009_Species_Files.rb b/Data/Scripts/010_Data/002_PBS data/009_Species_Files.rb index 8c65540b6..e019c8681 100644 --- a/Data/Scripts/010_Data/002_PBS data/009_Species_Files.rb +++ b/Data/Scripts/010_Data/002_PBS data/009_Species_Files.rb @@ -125,7 +125,7 @@ module GameData end def self.icon_bitmap(species, form = 0, gender = 0, shiny = false, shadow = false) - filename = self.icon_filename(species, form, gender,shiny, shadow) + filename = self.icon_filename(species, form, gender, shiny, shadow) return (filename) ? AnimatedBitmap.new(filename).deanimate : nil end diff --git a/Data/Scripts/011_Battle/001_Battler/001_PokeBattle_Battler.rb b/Data/Scripts/011_Battle/001_Battler/001_PokeBattle_Battler.rb index f0b096289..a63e93b6c 100644 --- a/Data/Scripts/011_Battle/001_Battler/001_PokeBattle_Battler.rb +++ b/Data/Scripts/011_Battle/001_Battler/001_PokeBattle_Battler.rb @@ -344,7 +344,7 @@ class PokeBattle_Battler def hasActiveAbility?(check_ability, ignore_fainted = false) return false if !abilityActive?(ignore_fainted) return check_ability.include?(@ability_id) if check_ability.is_a?(Array) - return check_ability == self.ability + return self.ability == check_ability end alias hasWorkingAbility hasActiveAbility? diff --git a/Data/Scripts/011_Battle/001_Battler/003_Battler_ChangeSelf.rb b/Data/Scripts/011_Battle/001_Battler/003_Battler_ChangeSelf.rb index 68c0d36b7..bbe2a09a5 100644 --- a/Data/Scripts/011_Battle/001_Battler/003_Battler_ChangeSelf.rb +++ b/Data/Scripts/011_Battle/001_Battler/003_Battler_ChangeSelf.rb @@ -37,7 +37,7 @@ class PokeBattle_Battler @battle.pbHideAbilitySplash(target) pbItemHPHealCheck else - msg = _INTL("{1} had its energy drained!",target.pbThis) if !msg || msg=="" + msg = _INTL("{1} had its energy drained!",target.pbThis) if nil_or_empty?(msg) @battle.pbDisplay(msg) if canHeal? amt = (amt*1.3).floor if hasActiveItem?(:BIGROOT) diff --git a/Data/Scripts/011_Battle/001_Battler/004_Battler_Statuses.rb b/Data/Scripts/011_Battle/001_Battler/004_Battler_Statuses.rb index 6d50e7078..733192ec3 100644 --- a/Data/Scripts/011_Battle/001_Battler/004_Battler_Statuses.rb +++ b/Data/Scripts/011_Battle/001_Battler/004_Battler_Statuses.rb @@ -484,7 +484,7 @@ class PokeBattle_Battler def pbConfuse(msg=nil) @effects[PBEffects::Confusion] = pbConfusionDuration @battle.pbCommonAnimation("Confusion",self) - msg = _INTL("{1} became confused!",pbThis) if !msg || msg=="" + msg = _INTL("{1} became confused!",pbThis) if nil_or_empty?(msg) @battle.pbDisplay(msg) PBDebug.log("[Lingering effect] #{pbThis}'s confusion count is #{@effects[PBEffects::Confusion]}") # Confusion cures @@ -551,7 +551,7 @@ class PokeBattle_Battler def pbAttract(user,msg=nil) @effects[PBEffects::Attract] = user.index @battle.pbCommonAnimation("Attract",self) - msg = _INTL("{1} fell in love!",pbThis) if !msg || msg=="" + msg = _INTL("{1} fell in love!",pbThis) if nil_or_empty?(msg) @battle.pbDisplay(msg) # Destiny Knot if hasActiveItem?(:DESTINYKNOT) && user.pbCanAttract?(self,false) diff --git a/Data/Scripts/011_Battle/003_Battle/002_PokeBattle_Battle.rb b/Data/Scripts/011_Battle/003_Battle/002_PokeBattle_Battle.rb index 3b31a72b3..e1ce075b6 100644 --- a/Data/Scripts/011_Battle/003_Battle/002_PokeBattle_Battle.rb +++ b/Data/Scripts/011_Battle/003_Battle/002_PokeBattle_Battle.rb @@ -401,7 +401,7 @@ class PokeBattle_Battle party.each_with_index do |pkmn,i| next if i=idxPartyEnd # Check the team only next if !pkmn || !pkmn.able? # Can't copy a non-fainted Pokémon or egg - ret = i if partyOrders[i]>partyOrders[ret] + ret = i if ret < 0 || partyOrders[i] > partyOrders[ret] end return ret end diff --git a/Data/Scripts/011_Battle/003_Battle/006_Battle_Action_Switching.rb b/Data/Scripts/011_Battle/003_Battle/006_Battle_Action_Switching.rb index 1e8030247..006f7c55b 100644 --- a/Data/Scripts/011_Battle/003_Battle/006_Battle_Action_Switching.rb +++ b/Data/Scripts/011_Battle/003_Battle/006_Battle_Action_Switching.rb @@ -170,7 +170,7 @@ class PokeBattle_Battle enemyParty = pbParty(idxBattler) if enemyParty[idxPartyNew].ability == :ILLUSION new_index = pbLastInTeam(idxBattler) - idxPartyForName = new_index if new_index >= 0 + idxPartyForName = new_index if new_index >= 0 && new_index != idxPartyNew end if pbDisplayConfirm(_INTL("{1} is about to send in {2}. Will you switch your Pokémon?", opponent.full_name, enemyParty[idxPartyForName].name)) @@ -257,7 +257,7 @@ class PokeBattle_Battle newPkmnName = party[idxParty].name if party[idxParty].ability == :ILLUSION new_index = pbLastInTeam(idxBattler) - newPkmnName = party[new_index].name if new_index >= 0 + newPkmnName = party[new_index].name if new_index >= 0 && new_index != idxParty end if pbOwnedByPlayer?(idxBattler) opposing = @battlers[idxBattler].pbDirectOpposing diff --git a/Data/Scripts/011_Battle/003_Battle/009_Battle_Action_Other.rb b/Data/Scripts/011_Battle/003_Battle/009_Battle_Action_Other.rb index 10a425704..17f869977 100644 --- a/Data/Scripts/011_Battle/003_Battle/009_Battle_Action_Other.rb +++ b/Data/Scripts/011_Battle/003_Battle/009_Battle_Action_Other.rb @@ -147,9 +147,7 @@ class PokeBattle_Battle @scene.pbRefreshOne(idxBattler) pbCommonAnimation("MegaEvolution2",battler) megaName = battler.pokemon.megaName - if !megaName || megaName=="" - megaName = _INTL("Mega {1}", battler.pokemon.speciesName) - end + megaName = _INTL("Mega {1}", battler.pokemon.speciesName) nil_or_empty?(megaName) pbDisplay(_INTL("{1} has Mega Evolved into {2}!",battler.pbThis,megaName)) side = battler.idxOwnSide owner = pbGetOwnerIndexFromBattlerIndex(idxBattler) diff --git a/Data/Scripts/011_Battle/005_Battle scene/005_PokeBattle_SceneMenus.rb b/Data/Scripts/011_Battle/005_Battle scene/005_PokeBattle_SceneMenus.rb index 07b3fa337..503ffad0f 100644 --- a/Data/Scripts/011_Battle/005_Battle scene/005_PokeBattle_SceneMenus.rb +++ b/Data/Scripts/011_Battle/005_Battle scene/005_PokeBattle_SceneMenus.rb @@ -538,7 +538,7 @@ class TargetMenuDisplay < BattleMenuBase @overlay.bitmap.clear textpos = [] @buttons.each_with_index do |button,i| - next if !button || @texts[i].nil? || @texts[i]=="" + next if !button || nil_or_empty?(@texts[i]) x = button.x-self.x+button.src_rect.width/2 y = button.y-self.y+2 textpos.push([@texts[i],x,y,2,TEXT_BASE_COLOR,TEXT_SHADOW_COLOR]) diff --git a/Data/Scripts/011_Battle/005_Battle scene/009_Scene_Animations.rb b/Data/Scripts/011_Battle/005_Battle scene/009_Scene_Animations.rb index 57c81a28b..0bd3ab098 100644 --- a/Data/Scripts/011_Battle/005_Battle scene/009_Scene_Animations.rb +++ b/Data/Scripts/011_Battle/005_Battle scene/009_Scene_Animations.rb @@ -480,7 +480,7 @@ class PokeBattle_Scene # Plays a common animation. def pbCommonAnimation(animName,user=nil,target=nil) - return if !animName || animName=="" + return if nil_or_empty?(animName) target = target[0] if target && target.is_a?(Array) animations = pbLoadBattleAnimations return if !animations diff --git a/Data/Scripts/013_Items/002_Item_Effects.rb b/Data/Scripts/013_Items/002_Item_Effects.rb index 366e16c58..00b9ebd65 100644 --- a/Data/Scripts/013_Items/002_Item_Effects.rb +++ b/Data/Scripts/013_Items/002_Item_Effects.rb @@ -946,7 +946,7 @@ ItemHandlers::UseOnPokemon.add(:DNASPLICERS,proc { |item,pkmn,scene| next false end # Fusing - if pkmn.fused==nil + if pkmn.fused.nil? chosen = scene.pbChoosePokemon(_INTL("Fuse with which Pokémon?")) next false if chosen<0 poke2 = $Trainer.party[chosen] @@ -999,7 +999,7 @@ ItemHandlers::UseOnPokemon.add(:NSOLARIZER,proc { |item,pkmn,scene| next false end # Fusing - if pkmn.fused==nil + if pkmn.fused.nil? chosen = scene.pbChoosePokemon(_INTL("Fuse with which Pokémon?")) next false if chosen<0 poke2 = $Trainer.party[chosen] @@ -1048,7 +1048,7 @@ ItemHandlers::UseOnPokemon.add(:NLUNARIZER,proc { |item,pkmn,scene| next false end # Fusing - if pkmn.fused==nil + if pkmn.fused.nil? chosen = scene.pbChoosePokemon(_INTL("Fuse with which Pokémon?")) next false if chosen<0 poke2 = $Trainer.party[chosen] diff --git a/Data/Scripts/016_UI/006_UI_Summary.rb b/Data/Scripts/016_UI/006_UI_Summary.rb index 45bd87e46..9090142e9 100644 --- a/Data/Scripts/016_UI/006_UI_Summary.rb +++ b/Data/Scripts/016_UI/006_UI_Summary.rb @@ -554,7 +554,7 @@ class PokemonSummary_Scene # Write map name Pokémon was received on mapname = pbGetMapNameFromId(@pokemon.obtain_map) mapname = @pokemon.obtain_text if @pokemon.obtain_text && !@pokemon.obtain_text.empty? - mapname = _INTL("Faraway place") if !mapname || mapname=="" + mapname = _INTL("Faraway place") if nil_or_empty?(mapname) memo += sprintf("%s\n",mapname) # Write how Pokémon was obtained mettext = [_INTL("Met at Lv. {1}.",@pokemon.obtain_level), @@ -573,7 +573,7 @@ class PokemonSummary_Scene memo += _INTL("{1} {2}, {3}\n",date,month,year) end mapname = pbGetMapNameFromId(@pokemon.hatched_map) - mapname = _INTL("Faraway place") if !mapname || mapname=="" + mapname = _INTL("Faraway place") if nil_or_empty?(mapname) memo += sprintf("%s\n",mapname) memo += _INTL("Egg hatched.\n") else diff --git a/Data/Scripts/016_UI/019_UI_PC.rb b/Data/Scripts/016_UI/019_UI_PC.rb index 53d84b696..ad84530f3 100644 --- a/Data/Scripts/016_UI/019_UI_PC.rb +++ b/Data/Scripts/016_UI/019_UI_PC.rb @@ -248,7 +248,7 @@ end def pbGetStorageCreator creator = Settings.storage_creator_name - creator = _INTL("Bill") if !creator || creator=="" + creator = _INTL("Bill") if nil_or_empty?(creator) return creator end diff --git a/Data/Scripts/016_UI/023_UI_MysteryGift.rb b/Data/Scripts/016_UI/023_UI_MysteryGift.rb index 42d75c76e..e9a9cfad8 100644 --- a/Data/Scripts/016_UI/023_UI_MysteryGift.rb +++ b/Data/Scripts/016_UI/023_UI_MysteryGift.rb @@ -138,7 +138,7 @@ def pbManageMysteryGifts pbMessageDisplay(msgwindow,_INTL("Searching for online gifts...\\wtnp[0]")) online = pbDownloadToString(MysteryGift::URL) pbDisposeMessageWindow(msgwindow) - if online=="" + if nil_or_empty?(online) pbMessage(_INTL("No online Mystery Gifts found.\\wtnp[20]")) online=[] else @@ -245,7 +245,7 @@ def pbDownloadMysteryGift(trainer) sprites["msgwindow"]=pbCreateMessageWindow pbMessageDisplay(sprites["msgwindow"],_INTL("Searching for a gift.\nPlease wait...\\wtnp[0]")) string = pbDownloadToString(MysteryGift::URL) - if string=="" + if nil_or_empty?(string) pbMessageDisplay(sprites["msgwindow"],_INTL("No new gifts are available.")) else online=pbMysteryGiftDecrypt(string) @@ -334,7 +334,7 @@ def pbMysteryGiftEncrypt(gift) end def pbMysteryGiftDecrypt(gift) - return [] if gift=="" + return [] if nil_or_empty?(gift) ret = Marshal.restore(Zlib::Inflate.inflate(gift.unpack("m")[0])) if ret ret.each do |gift| diff --git a/Data/Scripts/018_Alternate battle modes/003_OrgBattle.rb b/Data/Scripts/018_Alternate battle modes/003_OrgBattle.rb index c51f389b3..5e5d5f97b 100644 --- a/Data/Scripts/018_Alternate battle modes/003_OrgBattle.rb +++ b/Data/Scripts/018_Alternate battle modes/003_OrgBattle.rb @@ -80,7 +80,7 @@ class PBPokemon end for i in 1..maxconst val=mod.getName(i) - next if !val || val=="" + next if nil_or_empty?(val) return i if val==str end return 0 diff --git a/Data/Scripts/019_Utilities/001_Utilities.rb b/Data/Scripts/019_Utilities/001_Utilities.rb index 915876b06..5dadd04aa 100644 --- a/Data/Scripts/019_Utilities/001_Utilities.rb +++ b/Data/Scripts/019_Utilities/001_Utilities.rb @@ -89,19 +89,19 @@ end # Unused def hasConst?(mod,constant) - return false if !mod || !constant || constant=="" + return false if !mod || nil_or_empty?(constant) return mod.const_defined?(constant.to_sym) rescue false end # Unused def getConst(mod,constant) - return nil if !mod || !constant || constant=="" + return nil if !mod || nil_or_empty?(constant) return mod.const_get(constant.to_sym) rescue nil end # Unused def getID(mod,constant) - return nil if !mod || !constant || constant=="" + return nil if !mod || nil_or_empty?(constant) if constant.is_a?(Symbol) || constant.is_a?(String) if (mod.const_defined?(constant.to_sym) rescue false) return mod.const_get(constant.to_sym) rescue 0 diff --git a/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb b/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb index be939f5a9..1b5fdc59b 100644 --- a/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb +++ b/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb @@ -120,7 +120,7 @@ def pbAddForeignPokemon(pkmn, level = 1, owner_name = nil, nickname = nil, owner # Set original trainer to a foreign one pkmn.owner = Pokemon::Owner.new_foreign(owner_name || "", owner_gender) # Set nickname - pkmn.name = nickname[0, Pokemon::MAX_NAME_SIZE] + pkmn.name = nickname[0, Pokemon::MAX_NAME_SIZE] if !nil_or_empty?(nickname) # Recalculate stats pkmn.calc_stats if owner_name diff --git a/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb b/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb index 3b06e586d..04b7a7dc5 100644 --- a/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb +++ b/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb @@ -68,7 +68,7 @@ end #=============================================================================== def pbPlayTrainerIntroME(trainer_type) trainer_type_data = GameData::TrainerType.get(trainer_type) - return if !trainer_type_data.intro_ME || trainer_type_data.intro_ME == "" + return if nil_or_empty?(trainer_type_data.intro_ME) bgm = pbStringToAudioFile(trainer_type_data.intro_ME) pbMEPlay(bgm) end diff --git a/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb b/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb index a91c89bf2..92e6540fa 100644 --- a/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb +++ b/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb @@ -416,7 +416,7 @@ def pbTrainerTypeEditorNew(default_name) # Choose a name name = pbMessageFreeText(_INTL("Please enter the trainer type's name."), (default_name) ? default_name.gsub(/_+/, " ") : "", false, 30) - if name == "" + if nil_or_empty?(name) return nil if !default_name name = default_name end @@ -585,7 +585,7 @@ def pbTrainerBattleEditor end next if !tr_type tr_name = pbMessageFreeText(_INTL("Now enter the trainer's name."), "", false, 30) - next if tr_name == "" + next if nil_or_empty?(tr_name) tr_version = pbGetFreeTrainerParty(tr_type, tr_name) if tr_version < 0 pbMessage(_INTL("There is no room to create a trainer of that type and name.")) @@ -891,7 +891,7 @@ def pbItemEditorNew(default_name) # Choose a name name = pbMessageFreeText(_INTL("Please enter the item's name."), (default_name) ? default_name.gsub(/_+/, " ") : "", false, 30) - if name == "" + if nil_or_empty?(name) return if !default_name name = default_name end diff --git a/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb b/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb index 514e6b940..d35de8238 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb @@ -840,12 +840,12 @@ DebugMenuCommands.register("renameplayer", { "description" => _INTL("Rename the player."), "effect" => proc { trname = pbEnterPlayerName("Your name?", 0, Settings::MAX_PLAYER_NAME_SIZE, $Trainer.name) - if trname == "" && pbConfirmMessage(_INTL("Give yourself a default name?")) + if nil_or_empty?(trname) && pbConfirmMessage(_INTL("Give yourself a default name?")) trainertype = $Trainer.trainer_type gender = pbGetTrainerTypeGender(trainertype) trname = pbSuggestTrainerName(gender) end - if trname == "" + if nil_or_empty?(trname) pbMessage(_INTL("The player's name remained {1}.", $Trainer.name)) else $Trainer.name = trname @@ -865,11 +865,11 @@ DebugMenuCommands.register("randomid", { }) #=============================================================================== -# Information options +# Information editors #=============================================================================== DebugMenuCommands.register("editorsmenu", { "parent" => "main", - "name" => _INTL("Information options..."), + "name" => _INTL("Information editors..."), "description" => _INTL("Edit information in the PBS files, terrain tags, battle animations, etc."), "always_show" => true }) diff --git a/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb b/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb index d920ac15b..e89bf9e0f 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb @@ -82,21 +82,21 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand name = $data_system.switches[index+1] codeswitch = (name[/^s\:/]) val = (codeswitch) ? (eval($~.post_match) rescue nil) : $game_switches[index+1] - if val==nil + if val.nil? status = "[-]" colors = 0 codeswitch = true - elsif val + elsif val # true status = "[ON]" colors = 2 - else + else # false status = "[OFF]" colors = 1 end else name = $data_system.variables[index+1] status = $game_variables[index+1].to_s - status = "\"__\"" if !status || status=="" + status = "\"__\"" if nil_or_empty?(status) end name = '' if name==nil id_text = sprintf("%04d:",index+1) diff --git a/Data/Scripts/021_Compiler/001_Compiler.rb b/Data/Scripts/021_Compiler/001_Compiler.rb index 5b06d7a47..d6bd4aa2d 100644 --- a/Data/Scripts/021_Compiler/001_Compiler.rb +++ b/Data/Scripts/021_Compiler/001_Compiler.rb @@ -77,7 +77,7 @@ module Compiler end def csvQuote(str,always=false) - return "" if !str || str=="" + return "" if nil_or_empty?(str) if always || str[/[,\"]/] # || str[/^\s/] || str[/\s$/] || str[/^#/] str = str.gsub(/[\"]/,"\\\"") str = "\"#{str}\"" @@ -316,7 +316,7 @@ module Compiler def checkEnumField(ret,enumer) if enumer.is_a?(Module) begin - if ret=="" || !enumer.const_defined?(ret) + if nil_or_empty?(ret) || !enumer.const_defined?(ret) raise _INTL("Undefined value {1} in {2}\r\n{3}",ret,enumer.name,FileLineData.linereport) end rescue NameError @@ -327,7 +327,7 @@ module Compiler if !Kernel.const_defined?(enumer.to_sym) && GameData.const_defined?(enumer.to_sym) enumer = GameData.const_get(enumer.to_sym) begin - if ret == "" || !enumer.exists?(ret.to_sym) + if nil_or_empty?(ret) || !enumer.exists?(ret.to_sym) raise _INTL("Undefined value {1} in {2}\r\n{3}", ret, enumer.name, FileLineData.linereport) end rescue NameError @@ -337,7 +337,7 @@ module Compiler end enumer = Object.const_get(enumer.to_sym) begin - if ret=="" || !enumer.const_defined?(ret) + if nil_or_empty?(ret) || !enumer.const_defined?(ret) raise _INTL("Undefined value {1} in {2}\r\n{3}",ret,enumer.name,FileLineData.linereport) end rescue NameError @@ -362,16 +362,16 @@ module Compiler def checkEnumFieldOrNil(ret,enumer) if enumer.is_a?(Module) - return nil if ret=="" || !(enumer.const_defined?(ret) rescue false) + return nil if nil_or_empty?(ret) || !(enumer.const_defined?(ret) rescue false) return enumer.const_get(ret.to_sym) elsif enumer.is_a?(Symbol) || enumer.is_a?(String) if GameData.const_defined?(enumer.to_sym) enumer = GameData.const_get(enumer.to_sym) - return nil if ret == "" || !enumer.exists?(ret.to_sym) + return nil if nil_or_empty?(re) || !enumer.exists?(ret.to_sym) return ret.to_sym end enumer = Object.const_get(enumer.to_sym) - return nil if ret=="" || !(enumer.const_defined?(ret) rescue false) + return nil if nil_or_empty?(ret) || !(enumer.const_defined?(ret) rescue false) return enumer.const_get(ret.to_sym) elsif enumer.is_a?(Array) idx = findIndex(enumer) { |item| ret==item } @@ -402,7 +402,7 @@ module Compiler record.push(csvInt!(rec,lineno)) when "I" # Optional integer field = csvfield!(rec) - if field=="" + if nil_or_empty?(field) record.push(nil) elsif !field[/^\-?\d+$/] raise _INTL("Field {1} is not an integer\r\n{2}",field,FileLineData.linereport) @@ -413,7 +413,7 @@ module Compiler record.push(csvPosInt!(rec,lineno)) when "U" # Optional positive integer or zero field = csvfield!(rec) - if field=="" + if nil_or_empty?(field) record.push(nil) elsif !field[/^\d+$/] raise _INTL("Field '{1}' must be 0 or greater\r\n{2}",field,FileLineData.linereport) @@ -426,7 +426,7 @@ module Compiler record.push(field) when "V" # Optional positive integer field = csvfield!(rec) - if field=="" + if nil_or_empty?(field) record.push(nil) elsif !field[/^\d+$/] raise _INTL("Field '{1}' must be greater than 0\r\n{2}",field,FileLineData.linereport) @@ -443,7 +443,7 @@ module Compiler record.push(field.hex) when "X" # Optional hexadecimal number field = csvfield!(rec) - if field=="" + if nil_or_empty?(field) record.push(nil) elsif !field[/^[A-Fa-f0-9]+$/] raise _INTL("Field '{1}' is not a hexadecimal number\r\n{2}",field,FileLineData.linereport) @@ -454,7 +454,7 @@ module Compiler record.push(csvFloat!(rec,lineno)) when "F" # Optional floating point number field = csvfield!(rec) - if field=="" + if nil_or_empty?(field) record.push(nil) elsif !field[/^\-?^\d*\.?\d*$/] raise _INTL("Field {1} is not a floating point number\r\n{2}",field,FileLineData.linereport) @@ -465,7 +465,7 @@ module Compiler record.push(csvBoolean!(rec,lineno)) when "B" # Optional Boolean field = csvfield!(rec) - if field=="" + if nil_or_empty?(field) record.push(nil) elsif field[/^1|[Tt][Rr][Uu][Ee]|[Yy][Ee][Ss]|[Tt]|[Yy]$/] record.push(true) @@ -480,7 +480,7 @@ module Compiler record.push(field) when "N" # Optional name field = csvfield!(rec) - if field=="" + if nil_or_empty?(field) record.push(nil) elsif !field[/^(?![0-9])\w+$/] raise _INTL("Field '{1}' must contain only letters, digits, and\r\nunderscores and can't begin with a number.\r\n{2}",field,FileLineData.linereport) @@ -491,12 +491,12 @@ module Compiler record.push(csvfield!(rec)) when "S" # Optional string field = csvfield!(rec) - record.push((field=="") ? nil : field) + record.push((nil_or_empty?(field)) ? nil : field) when "q" # Unformatted text record.push(rec) rec = "" when "Q" # Optional unformatted text - if !rec || rec=="" + if nil_or_empty?(rec) record.push(nil) else record.push(rec) @@ -512,7 +512,7 @@ module Compiler record.push(csvEnumFieldOrInt!(field,schema[2+i-start],"",FileLineData.linereport)) when "Y" # Optional enumerable or integer field = csvfield!(rec) - if field=="" + if nil_or_empty?(field) record.push(nil) elsif field[/^\-?\d+$/] record.push(field.to_i) @@ -521,7 +521,7 @@ module Compiler end end end - break if repeat && rec=="" + break if repeat && nil_or_empty?(rec) end while repeat return (schema[1].length==1) ? record[0] : record end diff --git a/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb b/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb index 6ed90b026..aef3efb34 100644 --- a/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb +++ b/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb @@ -398,7 +398,7 @@ module Compiler for key in schema.keys # Skip empty properties, or raise an error if a required property is # empty - if contents[key].nil? || contents[key] == "" + if nil_or_empty?(contents[key]) if ["Name", "InternalName"].include?(key) raise _INTL("The entry {1} is required in PBS/pokemon.txt section {2}.", key, species_number) end @@ -583,7 +583,7 @@ module Compiler # Go through schema hash of compilable data and compile this section for key in schema.keys # Skip empty properties (none are required) - if contents[key].nil? || contents[key] == "" + if nil_or_empty?(contents[key]) contents[key] = nil next end @@ -922,7 +922,7 @@ module Compiler end new_format = true values = $~[1].split(',').collect! { |v| v.strip.to_i } - values[1] = 0 if !values[1] || values[1] == "" + values[1] = 0 if nil_or_empty?(values[1]) map_number = values[0] map_version = values[1] # Add map encounter's data to records