Author Topic: [XP] Gameover with Quick Restart Options  (Read 10066 times)

Offline karldaylo

  • Awakened Visionist
  • **
  • Posts: 59
  • LV: 3
  • Gender: Male
  • Anime Freak
    • View Profile
    • Better than Porn
[XP] Gameover with Quick Restart Options
« on: May 08, 2011, 07:44:45 AM »
Gameover Menu
Authors: Karl D
Version: 1.30
Type: GameOver Add-on
Key Term: Title / Save / Load / GameOver Add-on

Introduction

Inspired with Alundra's Gameover Scene,
this is my first script that i made, if you found a problem or logical error within my script, please tell me how should i resolve it :P

Features

  • Fade to black Before Gameover Graphics to show up
  • Optional Menu on Game over
  • Quick Restart/Quick Load last saved Game

Screenshots

(click to show/hide)

Demo

-None-

Script


(click to show/hide)

Instructions

Plug and Play

Compatibility

PLEASE LIST AS MANY COMPATIBILITY ISSUES AS YOU CAN IF THERE ARE ANY

Credits and Thanks

  • Karl D - creator
  • Game_guy - for helping me out how to figure thing out
  • Darklord and Blue Elf - for their autosave script(removed)

Author's Notes

My first time scripting, sorry if its full of bug(if ther is one)
« Last Edit: May 09, 2011, 09:59:16 AM by karldaylo »
RESPECT LIST:Blizzard, Game_guy, Foreverzer0, Winkio, Nathmatt

Offline Zexion

  • Addicted to LoL
  • Chaos User
  • ******
  • Posts: 1519
  • LV: 69
  • Gender: Male
  • My anaconda don't...jk it does
    • View Profile
Re: [XP] Gameover with Quick Restart Options
« Reply #1 on: May 08, 2011, 08:20:31 AM »
what does the quick restart do?

Offline Spaceman McConaughey

  • Legit Poo Poo Man
  • Lexima Warrior
  • *******
  • Posts: 2002
  • LV: 46
  • Gender: Male
  • muh murph
    • View Profile
    • Titties, titties, and more titties!
Re: [XP] Gameover with Quick Restart Options
« Reply #2 on: May 08, 2011, 08:25:43 AM »
It already says what it does.

Offline karldaylo

  • Awakened Visionist
  • **
  • Posts: 59
  • LV: 3
  • Gender: Male
  • Anime Freak
    • View Profile
    • Better than Porn
Re: [XP] Gameover with Quick Restart Options
« Reply #3 on: May 08, 2011, 09:41:45 AM »
what does the quick restart do?

it loads last saved game... the latest one... instantly
RESPECT LIST:Blizzard, Game_guy, Foreverzer0, Winkio, Nathmatt

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6591
  • LV: 407
  • Gender: Male
    • View Profile
Re: [XP] Gameover with Quick Restart Options
« Reply #4 on: May 08, 2011, 10:38:16 AM »
Great (first?) script. Easy, a bit redundant coding wise, but useful.

I was going to have an entire post on how the script could be more efficient, I than realized before I posted that I ended up writing an entire script for you. (Not cool) Anyways, just some pointers on improving this.
  • Instead of saving Quick.rxdata, you could check to see which last save was chosen
    • This'll require some work, add a variable to Game_System called "last_save"
    • In Scene_Save under on_decision, write before the line "write_data" add $game_system.last_save = @file_index
  • Instead of having a whole different game over scene (Scene_GameoverS) just use the original Scene_Gameover, no need to make another class. You're already making the old Scene_Gameover unusable, might as well just add in your code in there.
  • On your Quick Restart option, make it load up the last save by checking to see if there has been a last save.
    • check to see if $game_system.last_save is greater then 0, if so load the file
    • Get the filename by doing this "filename = "Save#{$game_system.last_save}.rxdata"

This will make it so Quick.rxdata isn't even saved. Less code, no need for that module to write and delete the save data. And its much more efficient over all since you're not saving data twice when you save. A bit redundant.

Offline karldaylo

  • Awakened Visionist
  • **
  • Posts: 59
  • LV: 3
  • Gender: Male
  • Anime Freak
    • View Profile
    • Better than Porn
Re: [XP] Gameover with Quick Restart Options
« Reply #5 on: May 08, 2011, 11:07:02 AM »
Thanks, and yes it is my first script :) well im not bit familliar with "varible" till this noon (my timezone)
and i just put things together up (the scene which has option menu in it is actually a copy of scene_end, i modify it so its usable to gameover scene :P ) and im not yet much fammiliar with ruby scripting,

and thats the reason why i made new class scene gameovers, the whole thing is actually just a put up together peices and modify it so it produce what i want it to do,...
but hey, im learning thanks to you :D now im able to make it better
(but there is onething bugging me, is this method of yours work even the game were closed after saving? is this part of the script will be it what state it was befor the game were closed?)

sorry for the bad english :)
RESPECT LIST:Blizzard, Game_guy, Foreverzer0, Winkio, Nathmatt

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6591
  • LV: 407
  • Gender: Male
    • View Profile
Re: [XP] Gameover with Quick Restart Options
« Reply #6 on: May 08, 2011, 11:27:13 AM »
The variable "last_save" that you added in Game_System gets saved with the Save file. So when you load a saved game, it'll load the last save file that saved game recorded. I could post my version of it real fast to show you how it works, maybe you could learn off of it.

EDIT:
This small code here, keeps track of the last save file that was saved to. Pretty small, nice and efficient. This does not have the game over yet and it does not have the loading of the save.
Code: [Select]
class Game_System
  attr_accessor :last_save
  alias gg_init_quick_restart_lat initialize
  def initialize
    @last_save = 0
    return gg_init_quick_restart_lat
  end
end
class Scene_Save
  alias gg_save_last_save_lat on_decision
  def on_decision(filename)
    $game_system.last_save = @file_index
    gg_save_last_save_lat
  end
end
« Last Edit: May 08, 2011, 11:29:54 AM by Gagmon »

Offline karldaylo

  • Awakened Visionist
  • **
  • Posts: 59
  • LV: 3
  • Gender: Male
  • Anime Freak
    • View Profile
    • Better than Porn
Re: [XP] Gameover with Quick Restart Options
« Reply #7 on: May 08, 2011, 11:33:17 AM »
thank you, im remakin it now :)
RESPECT LIST:Blizzard, Game_guy, Foreverzer0, Winkio, Nathmatt

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6591
  • LV: 407
  • Gender: Male
    • View Profile
Re: [XP] Gameover with Quick Restart Options
« Reply #8 on: May 08, 2011, 11:37:23 AM »
Heres my version of the script. It basically gives you an idea of how to setup a configuration, how to use it, how to alias old methods and call them for later. I didn't comment any of the code. I could if you want me to.
Code: [Select]
# Quick Restart
module Restart
  QUICK_RESTART_TEXT   = "Quick Restart"
  TO_TITLE_TEXT        = "Return to Title"
  EXIT_GAME_TEXT       = "Quit Game"
end
class Game_System
  attr_accessor :last_save
  alias gg_init_quick_restart_lat initialize
  def initialize
    @last_save = 0
    return gg_init_quick_restart_lat
  end
end
class Scene_Save
  alias gg_save_last_save_lat on_decision
  def on_decision(filename)
    $game_system.last_save = @file_index + 1
    gg_save_last_save_lat(filename)
  end
end
class Scene_Gameover
  def main
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.gameover($data_system.gameover_name)
    $game_system.bgm_play(nil)
    $game_system.bgs_play(nil)
    $game_system.me_play($data_system.gameover_me)
    choices = [Restart::QUICK_RESTART_TEXT, Restart::TO_TITLE_TEXT,
      Restart::EXIT_GAME_TEXT]
    @command_window = Window_Command.new(200, choices)
    @command_window.x = 320 - @command_window.width / 2
    @command_window.y = 240 - @command_window.height / 2
    if $game_system.last_save < 1
      @command_window.disable_item(0)
    end
    Graphics.transition(120)
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @sprite.bitmap.dispose
    @sprite.dispose
    @command_window.dispose
    Graphics.transition(40)
    Graphics.freeze
    if $BTEST
      $scene = nil
    end
  end
  def update
    @command_window.update
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0
        if $game_system.last_save < 1
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        do_quick_restart
      when 1
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Title.new
      when 2
        $game_system.se_play($data_system.decision_se)
        $scene = nil
      end
    end
  end
  def do_quick_restart
    file = File.open("Save#{$game_system.last_save}.rxdata", "rb")
    load = Scene_Load.new
    load.read_save_data(file)
    file.close
    $game_system.bgm_play($game_system.playing_bgm)
    $game_system.bgs_play($game_system.playing_bgs)
    $game_map.update
    $scene = Scene_Map.new
  end
end
« Last Edit: May 08, 2011, 11:40:34 AM by Gagmon »

Offline karldaylo

  • Awakened Visionist
  • **
  • Posts: 59
  • LV: 3
  • Gender: Male
  • Anime Freak
    • View Profile
    • Better than Porn
Re: [XP] Gameover with Quick Restart Options
« Reply #9 on: May 08, 2011, 11:59:10 AM »
thanks,... im updating my script.. thankyou for the help sir gg

EDITED: but there are problem that didnt show up on my previous script... when you die at new game, the game wont quick restart(if you didnt save at the new game,)

BUT, i could fix that befor making the hero gone to the dangerous wild world wothout saving :D

thanks again mr gg
« Last Edit: May 08, 2011, 12:05:41 PM by karldaylo »
RESPECT LIST:Blizzard, Game_guy, Foreverzer0, Winkio, Nathmatt

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6591
  • LV: 407
  • Gender: Male
    • View Profile
Re: [XP] Gameover with Quick Restart Options
« Reply #10 on: May 08, 2011, 12:14:02 PM »
Well in my script version, I simply disabled the Quick Restart command if a New Game hasn't saved yet.

Offline karldaylo

  • Awakened Visionist
  • **
  • Posts: 59
  • LV: 3
  • Gender: Male
  • Anime Freak
    • View Profile
    • Better than Porn
Re: [XP] Gameover with Quick Restart Options
« Reply #11 on: May 08, 2011, 12:41:25 PM »
ahahah :^_^': ididnt see that part... re-re edit the script  :P
RESPECT LIST:Blizzard, Game_guy, Foreverzer0, Winkio, Nathmatt

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6591
  • LV: 407
  • Gender: Male
    • View Profile
Re: [XP] Gameover with Quick Restart Options
« Reply #12 on: May 08, 2011, 12:48:40 PM »
Nice job, my only problem is this.
Code: [Select]
@continue_enabled = false
    for i in 0..3
      if FileTest.exist?("Save#{i+1}.rxdata")
        @continue_enabled = true
      end
    end
    # If continue is enabled, move cursor to "Load/Restart"
    # If disabled, display "Restart/Continue" text in gray
    if @continue_enabled
      @command_window.index = 1
    else
      @command_window.disable_item(0)
      @command_window.disable_item(1)
    end

Basically now if you start a new game and you have a save file, it'll let you click Quick Restart. Then you'll just get an error.
Under this
Code: [Select]
@continue_enabled = false
    for i in 0..3
      if FileTest.exist?("Save#{i+1}.rxdata")
        @continue_enabled = true
      end
    end
Add
Code: [Select]
@restart_enabled = true
if $game_system.last_save < 1
  @restart_enabled = false
end

Then change this
Code: [Select]
    # If continue is enabled, move cursor to "Load/Restart"
    # If disabled, display "Restart/Continue" text in gray
    if @continue_enabled
      @command_window.index = 1
    else
      @command_window.disable_item(0)
      @command_window.disable_item(1)
    end
To this.
Code: [Select]
    if @continue_enabled
      @command_window.index = 1
    else
      @command_window.disable_item(1)
    end
if @restart_enabled == false
  @command_window.disable_item(0)
end

Then change this
Code: [Select]
unless @continue_enabled
      # Play buzzer SE
      $game_system.se_play($data_system.buzzer_se)
      return
    end
to this
Code: [Select]
unless @restart_enabled
      # Play buzzer SE
      $game_system.se_play($data_system.buzzer_se)
      return
    end

*moves to database*

Offline karldaylo

  • Awakened Visionist
  • **
  • Posts: 59
  • LV: 3
  • Gender: Male
  • Anime Freak
    • View Profile
    • Better than Porn
Re: [XP] Gameover with Quick Restart Options
« Reply #13 on: May 08, 2011, 02:16:01 PM »
 :^_^': hahah basics....

i forget to change everything else after adding new statement :P sorry

*updated*
RESPECT LIST:Blizzard, Game_guy, Foreverzer0, Winkio, Nathmatt

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6591
  • LV: 407
  • Gender: Male
    • View Profile
Re: [XP] Gameover with Quick Restart Options
« Reply #14 on: May 08, 2011, 02:48:37 PM »
Looks good, I tested it, works what its for. Nice job for your first script.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 20013
  • LV: 651
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP] Gameover with Quick Restart Options
« Reply #15 on: May 09, 2011, 09:00:39 AM »
*slaps G_G for moving topic permaturely*

The Key Term does not exist and because of that, this script does not show up in the database index.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline karldaylo

  • Awakened Visionist
  • **
  • Posts: 59
  • LV: 3
  • Gender: Male
  • Anime Freak
    • View Profile
    • Better than Porn
Re: [XP] Gameover with Quick Restart Options
« Reply #16 on: May 09, 2011, 09:58:21 AM »
 :^_^': not his fault, my bad... i thought i dun have to include the other part of that term, ill fix it :)
RESPECT LIST:Blizzard, Game_guy, Foreverzer0, Winkio, Nathmatt

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 20013
  • LV: 651
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP] Gameover with Quick Restart Options
« Reply #17 on: May 09, 2011, 10:22:01 AM »
Yeah, but he should have notified you before or after he moved it. xD
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6591
  • LV: 407
  • Gender: Male
    • View Profile
Re: [XP] Gameover with Quick Restart Options
« Reply #18 on: May 09, 2011, 01:56:31 PM »
My bad >.< Moderators make mistakes too >.<

I swear to god it was there. O__O

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3255
  • LV: 298
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Gameover with Quick Restart Options
« Reply #19 on: May 10, 2011, 04:28:22 AM »
Congratulations on your first script!
That is a very proud moment for every beginning scripter,

* Levels +
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.