[XP] Autozapis - Wersja do druku
Ultima Forum
[XP] Autozapis - Wersja do druku

+- Ultima Forum (https://forum.ultimateam.pl)
+-- Dział: RPG Maker (/Forum-RPG-Maker)
+--- Dział: Skrypty (/Forum-Skrypty)
+---- Dział: RGSS (/Forum-RGSS)
+---- Wątek: [XP] Autozapis (/Thread-XP-Autozapis)



Autozapis - Narzew - 19-05-13 22:21

~ Autozapis ~


Krótki opis:
Skrypt na autozapis waszej gry (zapisz przez jedno polecenie w zdarzeniu)

Skrypt:
Spoiler: (Otwórz)
Dodatkowe informacje:
Skrypt stary i przestarzały, ale działa. Może kiedyś napisze optymalniejszą wersję.


RE: Autozapis - Soul - 16-07-13 16:15

O..o... Dopiero teraz to zobaczyłem. Dzięki.


RE: Autozapis - dudekmenPL - 29-01-16 21:34

Sory ale mam błąd w ostaniej linijce(66)

:Name error occurred..
:uninitalized constant S1

Co mogło go spowodować ?

P.S błąd wyskakuje przy starcie gry


RE: Autozapis - RATISOFT - 30-01-16 00:14

Przede wszystkim nie "S1" tylko "Sl" (małe L) ;)

Błąd sugeruje brak zainicjowania stałej o tej nazwie. Constant w języku RUBY może być definiowane w klasach lub modułach.
Niestety nie mam RM XP żeby przetestować i wskazać dokładne rozwiązanie ale może lepiej spróbuj użyć innego skryptu?

Kod:
#===============================================================================​
#  Liz's Autosave Script
#-------------------------------------------------------------------------------
#  Just place this script below all default scripts and above main.
#  It will handle itself.
#
#  To Auto-save:
#    Use the 'Script...' command and input:
#    Autosave.save
#===============================================================================​
module Autosave

  def self.save
    filename = make_filename(0)
    file = File.open(filename, "wb")
    write_save_data(file)
    file.close
  end

  def self.write_save_data(file)
    # Make character data for drawing save file
    characters = []
    for i in 0...$game_party.actors.size
          actor = $game_party.actors[i]
          characters.push([actor.character_name, actor.character_hue])
    end
    # Write character data for drawing save file
    Marshal.dump(characters, file)
    # Wrire frame count for measuring play time
    Marshal.dump(Graphics.frame_count, file)
    # Increase save count by 1
    $game_system.save_count += 1
    # Save magic number
    # (A random value will be written each time saving with editor)
    $game_system.magic_number = $data_system.magic_number
    # Write each type of game object
    Marshal.dump($game_system, file)
    Marshal.dump($game_switches, file)
    Marshal.dump($game_variables, file)
    Marshal.dump($game_self_switches, file)
    Marshal.dump($game_screen, file)
    Marshal.dump($game_actors, file)
    Marshal.dump($game_party, file)
    Marshal.dump($game_troop, file)
    Marshal.dump($game_map, file)
    Marshal.dump($game_player, file)
  end

  def self.make_filename(file_index)
    return "Save#{file_index + 1}.rxdata"
  end
end


class Window_SaveFile < Window_Base
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    if @file_index == 0
          name = "Autosave"
          if $scene.is_a?(Scene_Save)
            self.contents.font.color = disabled_color
          end
    else
          name = "File #{@file_index}"
          self.contents.font.color = normal_color
    end
    self.contents.draw_text(4, 0, 600, 32, name)
    @name_width = contents.text_size(name).width
    if @file_exist
          for i in 0...@characters.size
            bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
            cw = bitmap.rect.width / 4
            ch = bitmap.rect.height / 4
            src_rect = Rect.new(0, 0, cw, ch)
            x = 300 - @characters.size * 32 + i * 64 - cw / 2
            self.contents.blt(x, 68 - ch, bitmap, src_rect)
          end
          hour = @total_sec / 60 / 60
          min = @total_sec / 60 % 60
          sec = @total_sec % 60
          time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
          self.contents.font.color = normal_color
          self.contents.draw_text(4, 8, 600, 32, time_string, 2)
          self.contents.font.color = normal_color
          time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
          self.contents.draw_text(4, 40, 600, 32, time_string, 2)
    end
  end
end

class Scene_Save < Scene_File

  alias lizzie_autosave_ss_ondec on_decision

  def on_decision(filename)
    if filename.include?("Save1.rxdata")
          $game_system.se_play($data_system.buzzer_se)
          return
    end
    lizzie_autosave_ss_ondec(filename)
  end
end



RE: Autozapis - dudekmenPL - 30-01-16 09:35

Możesz mi powiedzieć jeszcze jak się wywołuje ten skrypt lub co ile robi autosava ?


RE: Autozapis - Szymkim213 - 30-01-16 10:40

Pisze:
To Auto-Save:
Use the "Script..." command and input: Autosave.save
Tłumaczenie:
Żeby użyć:
Użyj komendy "Skrypt..." i wpisz: Autosave.save


RE: Autozapis - dudekmenPL - 30-01-16 10:49

Ale wywołaniem skryptu czy komentarzem ?

[re]Próbowałem tak i tak i nie działa ;/ w sumie to już nw co robię źle