I have a script request on how to check if my switch is true or not. You would think that I would've easily found this, but not so, I can't seem to make it work. Here's what I have so far, but it obviously won't work...
Spoiler
if $game_switches[1]
DEFAULT_BATTLE_SYSTEM = :yctb
else
DEFAULT_BATTLE_SYSTEM = :yctb
end
Basically, if Switch 1 is On, I want the default battle system to be set to :yctb and if it's off, I want it set to :dtb. I'm sure it's really simple, but there's just something I'm missing. I want it all done via scripting, don't want any event calls or anything.
Single-handedly putting an end to the monopolisation of the scripting forums. Proud member of The Underground and JIFZ-NFPZ.
Have you ever wanted to attach switches, variables, and various information onto your Actors, Events, Classes, Skills, Armors, Items, Weapons, and Skills? Now you can. The Self Data Suite -- The Most Extensive Set of Scripts Around (also available for RPG Maker XP and VX)
#============================================================================== # # ▼ Yanfly Engine Ace - Ace Battle Engine v1.22 # -- Last Updated: 2012.03.04 # -- Level: Normal, Hard # -- Requires: n/a # #============================================================================== $imported = {} if $imported.nil? $imported["YEA-BattleEngine"] = true #============================================================================== # ▼ Updates # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # 2012.03.04 - Bug fixed: Input crash bug. # 2012.02.13 - Bug fixed: Odd Victory game crash fixed. # 2012.02.12 - Bug fixed: Displayed damage in combat log is correct now. # 2012.01.29 - Visual Changes: Buff stacks now show one popup upon one skill. # 2012.01.24 - Compatibility Update: Enemy Levels # 2012.01.18 - Bug Fixed: Help Window clears text upon selecting nil items. # 2012.01.11 - Added tag for multi-hit skills to play an # animation only once. # - Reduced lag from battle system constantly recreating bitmaps. # 2012.01.10 - Compatibility Update: Battle System FTB # 2012.01.09 - Anticrash methods implemented. # - Damage Popups are now separate for damage formulas and recovery. # 2012.01.05 - Bug fixed: Game no longer crashes with escape skills/items. # 2012.01.02 - Compatibility Update: Target Manager # - Added Option: AUTO_FAST # - Random hits now show animations individually. # 2011.12.30 - Compatibility Update: Enemy Levels # - Added Option to center the actors in the HUD. # 2011.12.27 - Bug fixed: TP Damage skills and items no longer crash game. # - Default battle system bug fixes are now included from YEA's Ace # Core Engine. # - Groundwork is also made to support future battle system types. # - Multi-hit actions no longer linger when a target dies during the # middle of one of the hits. # - Compatibility Update: Lunatic Objects v1.02 # 2011.12.26 - Bug fixed: Multi-hit popups occured even after an enemy's dead. # 2011.12.22 - Bug fixed: Elemental Resistance popup didn't show. # 2011.12.20 - Bug fixed: Death state popups against immortal states. # - Bug fixed: During State popup fix. # - Added HIDE_POPUP_SWITCH. # 2011.12.17 - Compatibiilty Update: Cast Animations # 2011.12.15 - Compatibility Update: Battle Command List # 2011.12.14 - Compatibility Update: Lunatic Objects # 2011.12.13 - Compatibility Update: Command Party # 2011.12.12 - Bug fixed: Turn stalling if no inputable members. # 2011.12.10 - Compatibility update for Automatic Party HUD. # - Popup graphical bug fixed. # - Bug fixed: Didn't wait for boss dead animations. # - Bug fixed: Surprise attacks that froze the game. # - Bug fixed: Popups didn't show for straight recovery effects. # 2011.12.08 - Finished Script. # 2011.12.04 - Started Script. # #============================================================================== # ▼ Introduction # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # Ace Battle Engine works as a foundation for future battle engine add-ons. It # allows for easier management of the battle engine without adding too many # features, allowing users to customize what they want as they see fit. While # the Ace Battle Engine isn't an entirely new engine, it gives users control # that RPG Maker VX Ace didn't originally give them. # # Furthermore, this script provides some new features. They are as follows: # # ----------------------------------------------------------------------------- # Animation Fixes # ----------------------------------------------------------------------------- # Though the Yanfly Engine Ace - Ace Core Engine script contains these fixes, # these fixes are included in this script as well to ensure it's working for # the battle script in the event someone chooses not to work with the Ace Core # Engine script. The animation fixes prevent excessive animation overlaying # (and making the screen look really ugly) and prevents animation clashing # between two dual wielding normal attack animations. # # ----------------------------------------------------------------------------- # Enemy Animations # ----------------------------------------------------------------------------- # Enemies now show battle animations when they deliver attacks and skills # against the player's party. Before in RPG Maker VX Ace, it was nothing more # than just sound effects and the screen shaking. Now, animations play where # the status window is and relative to the position of each party member. # # ----------------------------------------------------------------------------- # Left/Right Command Selection # ----------------------------------------------------------------------------- # While choosing actions, the player can press Left or Right to move freely # between (alive) actors to change their skills. Players no longer have to # cancel all the way back to change one person's skill and reselect everything. # On that note, there is now the option that when a battle starts or at the # end of a turn, players will start immediately at command selection rather # than needing to select "Fight" in the Party Command Window. # # ----------------------------------------------------------------------------- # Popups # ----------------------------------------------------------------------------- # Dealing damage, inflicting states, adding buffs, landing critical hits, # striking weaknesses, missing attacks, you name it, there's probably a popup # for it. Popups deliver information to the player in a quick or orderly # fashion without requiring the player to read lines of text. # # ----------------------------------------------------------------------------- # Targeting Window # ----------------------------------------------------------------------------- # When targeting enemies, the window is no longer displayed. Instead, the # targeted enemies are highlighted and their names are shown at the top of the # screen in a help window. Another thing that's changed is when skills that # target multiple targets are selected, there is a confirmation step that the # player must take before continuing. In this confirmation step, all of the # multiple targets are selected and in the help window would display the scope # of the skill (such as "All Foes" or "Random Foes"). RPG Maker VX Ace skipped # this step by default. # # ----------------------------------------------------------------------------- # Toggling On and Off Special Effects and Text # ----------------------------------------------------------------------------- # Not everybody likes having the screen shake or the enemies blink when they # take damage. These effects can now be toggled on and off. Certain text can # also be toggled on and off from appearing. A lot of the displayed text has # been rendered redundant through the use of popups. # # ----------------------------------------------------------------------------- # Visual Battle Status Window # ----------------------------------------------------------------------------- # Rather than just having rows of names with HP and MP bars next to them, the # Battle Status Window now displays actors' faces and their gauges aligned at # the bottom. More status effects can be shown in addition to showing more # members on screen at once. The Battle Status Window is also optimized to # refresh less (thus, removing potential lag from the system). # # ----------------------------------------------------------------------------- # Window Position Changes # ----------------------------------------------------------------------------- # Windows such as the Skill Window and Item Window have been rearranged to # always provide the player a clear view of the battlefield rather than opening # up and covering everything. As such, the window positions are placed at the # bottom of the screen and are repositioned. # #============================================================================== # ▼ Instructions # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # To install this script, open up your script editor and copy/paste this script # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save. # # ----------------------------------------------------------------------------- # Skill Notetags - These notetags go in the skills notebox in the database. # ----------------------------------------------------------------------------- # # Causes the action to display the action animation only once, even if it's a # multi-hit action. This is used primarily for non-all scope targeting. # # ----------------------------------------------------------------------------- # Item Notetags - These notetags go in the items notebox in the database. # ----------------------------------------------------------------------------- # # Causes the action to display the action animation only once, even if it's a # multi-hit action. This is used primarily for non-all scope targeting. # # ----------------------------------------------------------------------------- # Enemy Notetags - These notetags go in the enemy notebox in the database. # ----------------------------------------------------------------------------- # # # Changes the normal attack animation of the particular enemy to animation x. # Attack animation 1 is the first one that plays. If there's a second animation # then the second one will play after in mirrored form. # # ----------------------------------------------------------------------------- # State Notetags - These notetags go in the state notebox in the database. # ----------------------------------------------------------------------------- # # # # Status effects now create popups whenever they're inflicted. However, if you # don't like that a certain status effect uses a particular colour setting, # change "string" to one of the rulesets below to cause that popup to use a # different ruleset. # # # # # Not everybody wants status effects to show popups when inflicted. When this # is the case, insert the respective tag to hide popups from appearing when the # state is added, removed, or during the stand-by phases. # # ----------------------------------------------------------------------------- # Debug Tools - These tools only work during Test Play. # ----------------------------------------------------------------------------- # - F5 Key - # Recovers all actors. Restores their HP and MP to max. Does not affect TP. # All states and buffs are removed whether they are positive or negative. # # - F6 Key - # Sets all actors to have 1 HP, 0 MP, and 0 TP. States are unaffected. # # - F7 Key - # Sets all actors to have max TP. Everything else is unaffected. # # - F8 Key - # Kills all enemies in battle. Ends the battle quickly. # #============================================================================== # ▼ Compatibility # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that # it will run with RPG Maker VX without adjusting. # #============================================================================== module YEA module BATTLE #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # - General Battle Settings - #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # These settings are adjusted for the overall battle system. These are # various miscellaneous options to adjust. Each of the settings below will # explain what they do. Change default enemy battle animations here, too. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- BLINK_EFFECTS = false # Blink sprite when damaged? FLASH_WHITE_EFFECT = true # Flash enemy white when it starts an attack. SCREEN_SHAKE = false # Shake screen in battle? SKIP_PARTY_COMMAND = true # Skips the Fight/Escape menu. AUTO_FAST = true # Causes message windows to not wait. ENEMY_ATK_ANI = 36 # Sets default attack animation for enemies. # If this switch is ON, popups will be hidden. If OFF, the popups will be # shown. If you do not wish to use this switch, set it to 0. HIDE_POPUP_SWITCH = 0 #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # - Battle Status Window - #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # This sets the default battle system your game will use. If your game # doesn't have any other battle systems installed, it will use :dtb. # # Battle System Requirement # :dtb - Default Turn Battle. Default system. # :ftb - YEA Battle System Add-On: Free Turn Battle #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- DEFAULT_BATTLE_SYSTEM = :dtb # Default battle system set.
Sorry, the above code isn't split into lines...
Thanks for any and all help, James
EDIT: In the above code, I only showed down to where it says after this line, don't edit. EDIT2: In the above code, I shortened it so it only shows from the beginning to the line that sets the Default Battle System. EDIT3: Is there something I have to call, or a class or def I have to initialize or whatever before I get to this line? That might be the problem.
Edited by chessplayerjames, 25 May 2012 - 07:45 AM.
So you want to test the switch in the settings area?
That won't work since it's not inside a method.
You can only set variables/constants out of methods.
You'd have to search for the place where the script asks for the DEFAULT_BATTLE_SYSTEM and decides what to do.
At least that's what I guess before looking at it in detail
Yeah, in test mode just press F9. You will see a list of switch and variables.
If you want to use 2 different battle system, I recommend using this script, it will allow you to do it : Multiple Battle Systems "This script allows you to create multiple battle managers that may have their own unique set of battle logic. Different battle scenes with their own battle windows can be added as well."
$game_switches is only instantiated AFTER you start a game. If you have your initial code somewhere that causes it to be run on launch, $game_switches will not exist.
If you want the player to determine which battle system to use, you will either have to use a global variable that gets set from the main menu, or if you want to use $game_switches, you'll have to check it and set the battle system sometime after the new game is initialized.
Bump. I thought checking for switches should've been really easy? What am I doing wrong? (Look in the above error).
Thanks for any and all help, James
The problem is that when you check that item in the array, the array itself doesn't exist in memory yet and that's why Ruby it's telling you that's nil.
You need to do that operation somewhere else, after the code of creating the array (which is in DataManager line 87) has been executed already.