Global switches script

Discussion in 'RGSS3 Script Requests' started by Benja, Sep 25, 2015.

  1. Benja

    Benja Lead Developer Veteran

    Messages:
    131
    Likes Received:
    28
    First Language:
    English
    Primarily Uses:
    RMVXA
    Recently Hime made an amazing script for me in order to create a boss rush, the problem is, I want this boss rush to be unlocked when the game is beaten, so I was hoping someone would be kind enough to make a script for me that has a switch I can turn on, and it would change the title menu. 

    If needed here's the hime script:

    Code:
    module TH  module Special_Map_Command      # The map that the player will be sent to upon choosing the special command.    Map_ID = 85        # Name of the command that will be shown in the title screen    Name = "Boss Rush"        # A formula that determines whether the command will be displayed    Condition = "true"  endendmodule DataManager  def self.setup_boss_rush    create_game_objects    $game_party.setup_starting_members    $game_map.setup(TH::Special_Map_Command::Map_ID)    $game_player.moveto(1, 1)    $game_player.refresh    Graphics.frame_count = 0  endendclass Window_TitleCommand < Window_Command  alias :th_special_map_command_make_command_list :make_command_list  def make_command_list    th_special_map_command_make_command_list        add_command(TH::Special_Map_Command::Name, :boss_rush) if boss_rush_enabled?  end    #-------------  # Whether boss rush should be enabled or not  #-------------  def boss_rush_enabled?    eval(TH::Special_Map_Command::Condition)  endendclass Scene_Title    alias :th_special_map_command_create_command_window :create_command_window  def create_command_window    th_special_map_command_create_command_window    @command_window.set_handler(:boss_rush, method(:command_boss_rush))  end    def command_boss_rush    DataManager.setup_boss_rush    close_command_window    fadeout_all    $game_map.autoplay    SceneManager.goto(Scene_Map)  endend
     
    #1
  2. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    179
    Location:
    La La Land
    First Language:
    Meowish
    What you need is not a global switch but a global save file to tell the game you have cleared the game. A global switch gets reset every time you close the game but a global save file stay there as long as it's created.

    Have you tried one of those new game+ scripts out there?
     
    #2
  3. Benja

    Benja Lead Developer Veteran

    Messages:
    131
    Likes Received:
    28
    First Language:
    English
    Primarily Uses:
    RMVXA
    New game + isn't exactly what I'm looking for, and I have no clue how to change it to be what I need.
     
    #3
  4. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    179
    Location:
    La La Land
    First Language:
    Meowish
    As far as i can tell from that script, Tsukihime has done everything for you except the condition part.

    There's should be a file check method in New Game+ that checks if new game+ save files exist or not, simply place that in the condition part will work.

    If you do not plan to use New Game+ and plan to add your own global save file at game end, look for scripts that allow you to create file then do a file check on that in the condition part.

    Try this script, in the settings area set the save folder to '.' if your save files are using the game default folder.

    Then, in the @Doc1 part, simply edit that to "Game Cleared", or just leave them be, it doesn't really matter what data we write into the file :p

    When done setting those up:

    Now you can create a file call "game_cleared.rvdata2" at the end of the game using the script call in your ending event:

    txt_save("DOC1", "game_cleared.rvdata2")This should create a file name game_cleared.rvdata2 in your game folder if you set it up right.

    ----------

    When all those are ready, add this line to Tsukihime's script condition (replace "true")

    Condition = File.exist?('.\game_cleared.rvdata2')-----------

    So next time, when the file exist the boss rush will be available. When the file isn't there, the boss rush will be disabled.
     
    Last edited by a moderator: Sep 25, 2015
    #4
    Tsukihime likes this.
  5. Benja

    Benja Lead Developer Veteran

    Messages:
    131
    Likes Received:
    28
    First Language:
    English
    Primarily Uses:
    RMVXA
    Script boss rush line 37: TypeError has occurred

    Can't convert false into a string
     
    Last edited by a moderator: Sep 25, 2015
    #5
  6. Sixth

    Sixth Veteran Veteran

    Messages:
    2,133
    Likes Received:
    801
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    You don't need that . if you want to check in the game's root folder.


    Try this:

    Code:
    Condition = File.exist?("game_cleared.rvdata2")
     
    #6
  7. Benja

    Benja Lead Developer Veteran

    Messages:
    131
    Likes Received:
    28
    First Language:
    English
    Primarily Uses:
    RMVXA
    Same error

    Script boss rush line 37: TypeError has occurred

    Can't convert false into a string
     
    #7
  8. Sixth

    Sixth Veteran Veteran

    Messages:
    2,133
    Likes Received:
    801
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    That's not the same error than, is it? :D


    Since it's an eval call try this:

    Code:
    Condition = "#{File.exist?("game_cleared.rvdata2")}"
     
    #8
  9. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    179
    Location:
    La La Land
    First Language:
    Meowish
    Convert line 37 from:

    eval(TH::Special_Map_Command::Condition)

    to

    TH::Special_Map_Command::Condition
     
    #9
  10. Benja

    Benja Lead Developer Veteran

    Messages:
    131
    Likes Received:
    28
    First Language:
    English
    Primarily Uses:
    RMVXA
    Meowface's solution worked! Thanks a ton!
     
    #10
  11. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    179
    Location:
    La La Land
    First Language:
    Meowish
    You're welcome! And congratulations on your progress! ;)
     
    #11
  12. Sixth

    Sixth Veteran Veteran

    Messages:
    2,133
    Likes Received:
    801
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    If you do it like that, the condition will get stored at game startup. It will NOT change during the game, only after the game is restarted.


    So, if the player finishes the game, gets this file created and returns to the title screen, the new option will NOT be there, until the game is restarted.
     
    #12
  13. Benja

    Benja Lead Developer Veteran

    Messages:
    131
    Likes Received:
    28
    First Language:
    English
    Primarily Uses:
    RMVXA
    How would I make it do otherwise?
     
    #13
  14. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    179
    Location:
    La La Land
    First Language:
    Meowish
    Convert line 37 from:

    eval(TH::Special_Map_Command::Condition)

    to

    File.exist?('.\game_cleared.rvdata2')
     
    #14
  15. Benja

    Benja Lead Developer Veteran

    Messages:
    131
    Likes Received:
    28
    First Language:
    English
    Primarily Uses:
    RMVXA
    Thanks a ton (again) MeowFace!
     
    #15
  16. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    179
    Location:
    La La Land
    First Language:
    Meowish
    You're welcome! And congratulations(again) on your progress! ;)
     
    #16

Share This Page