collapse collapse

 Community


 User Info




Willkommen Gast. Bitte einloggen oder registrieren.

 Partnerseiten

rpgvx.net

Das Forum ist offline

Autor Thema: 6 Save Files v.0.2 (Erstes Script)  (Gelesen 1170 mal)

Offline lenni96

  • Ralph
  • *
  • Beiträge: 14
6 Save Files v.0.2 (Erstes Script)
« am: September 29, 2010, 22:29:48 »
Bitte beachtet das es mein erstes Script ist bevor ihr mit zu harter Kritik kommt,
danke.


Kurze erklärung:
Es erweitert das Normale Speicher Menü um 2 weiter Speicherplätze.
Es ist mein erstes Script und ich lerne noch, das heißt ich werde es nach und nach noch verbessern.

Den Code über Main einfügen

Changelog v.0.2
Spoiler for Hiden:
Zitat
-Varierende Namen für "Gespeichert" und "Nicht gespeichert" hinzu gefügt.
-Kompatiblitätsprobleme behoben

v.0.2
Spoiler for Hiden:
#==============================================================================
# ** 6 Save Files
#------------------------------------------------------------------------------
#  (C)By Lenni96 and Ranack
#  
#  v.0.2
#
#  Deutsch:
#   Bitte ändert zuerst einmal die Variabeln.
#
#  English:
#   Please change the variables first.
#==============================================================================

class Window_SaveFile < Window_Base
  #--------------------------------------------------------------------------
  # * Variables
  #    Please Change the variable with the names for saved file and unsaved
  #    file.
  #
  #    Bitte ändere die Variabeln für die Namen für gespeicherte und nicht
  #    gespeicherte datei.
  #--------------------------------------------------------------------------
       $filenameunsaved = "unsaved file"
       $filenamesaved = "saved file"
  #--------------------------------------------------------------------------
  #
  #
  #
  #--------------------------------------------------------------------------
  attr_reader   :filename                 # filename
  attr_reader   :file_exist               # file existence flag
  attr_reader   :time_stamp               # timestamp
  attr_reader   :selected                 # selected
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     file_index : save file index (0-3)
  #     filename   : filename
  #--------------------------------------------------------------------------
  def initialize(file_index, filename)
    super(0, 56 + file_index % 6 * 60, 544, 60)
    @file_index = file_index
    @filename = filename
    load_gamedata
    refresh
    @selected = false
  end
  #--------------------------------------------------------------------------
  # * Load Partial Game Data
  #    By default, switches and variables are not used (for expansion use,
  #    such as displaying place names)
  #--------------------------------------------------------------------------
  def load_gamedata
    @time_stamp = Time.at(0)
    @file_exist = FileTest.exist?(@filename)
    if @file_exist
      file = File.open(@filename, "r")
      @time_stamp = file.mtime
      begin
        @characters     = Marshal.load(file)
        @frame_count    = Marshal.load(file)
        @last_bgm       = Marshal.load(file)
        @last_bgs       = Marshal.load(file)
        @game_system    = Marshal.load(file)
        @game_message   = Marshal.load(file)
        @game_switches  = Marshal.load(file)
        @game_variables = Marshal.load(file)
        @total_sec = @frame_count / Graphics.frame_rate
      rescue
        @file_exist = false
      ensure
        file.close
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    if @file_exist
    name = $filenamesaved
  else
    name = $filenameunsaved
    end
    self.contents.draw_text(4, 0, 200, WLH, name)
    @name_width = contents.text_size(name).width
    if @file_exist
      draw_playtime(0, 4, contents.width - 4, 2)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Party Characters
  #     x : Draw spot X coordinate
  #     y : Draw spot Y coordinate
  #--------------------------------------------------------------------------
  def draw_party_characters(x, y)
    for i in 0...@characters.size
      name = @characters[i][0]
      index = @characters[i][1]
      draw_character(name, index, x + i * 48, y)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Play Time
  #     x : Draw spot X coordinate
  #     y : Draw spot Y coordinate
  #     width : Width
  #     align : Alignment
  #--------------------------------------------------------------------------
  def draw_playtime(x, y, width, align)
    hour = @total_sec / 60 / 60
    min = @total_sec / 60 % 60
    sec = @total_sec % 60
    time_string = sprintf("Spielzeit: %02d:%02d:%02d", hour, min, sec)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, width, WLH, time_string, 2)
  end
  #--------------------------------------------------------------------------
  # * Set Selected
  #     selected : new selected (true = selected, false = unselected)
  #--------------------------------------------------------------------------
  def selected=(selected)
    @selected = selected
    update_cursor
  end
  #--------------------------------------------------------------------------
  # * Update cursor
  #--------------------------------------------------------------------------
  def update_cursor
    if @selected
      self.cursor_rect.set(0, 0, @name_width + 8, WLH)
    else
      self.cursor_rect.empty
    end
  end
end

Credits müssen nicht sein, wenn doch dann an ranack und mich

Kritik und Lob sind erwünscht
« Letzte Änderung: Oktober 01, 2010, 14:57:53 von lenni96 »

Re:6 Save Files v.0.2 (Erstes Script)

Offline Cress2009

  • Database-Verunstalter
  • **
  • Beiträge: 134
Re:6 Save Files v.0.2 (Erstes Script)
« Antwort #1 am: September 30, 2010, 20:50:32 »
Hey willkommen im Forum,

Ich finde es ist ne simple aber gute Idee.
Auch wenn ich mit 6 Savefiles nicht viel anfangen kann, heißt es nicht
dass es jemand anderes auch nicht braucht.

~Cress

 


 Bild des Monats

rooftop party

Views: 3581
By: papilion

 Umfrage

  • Wer soll das BdM gewinnen?
  • Dot Kandidat 1
  • 3 (25%)
  • Dot Kandidat 2
  • 1 (8%)
  • Dot Kandidat 3
  • 2 (16%)
  • Dot Kandidat 4
  • 0 (0%)
  • Dot Kandidat 5
  • 6 (50%)
  • Stimmen insgesamt: 12
  • View Topic

 Schnellsuche





SimplePortal 2.3.3 © 2008-2010, SimplePortal