RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

Load switches with script event command

Started by Ultimaodin, May 15, 2008, 11:35:26 AM

0 Members and 1 Guest are viewing this topic.

Ultimaodin

Alright I hit a small bump:

I want to load all the switches from file 1 but I can't work out how!

I tried this:

$game_switches = load(1)

which came up with the error:

Cannot convert fixnum into string.


I then tried:

$game_switches = Marshal.load(1)

which came up with the error:

instance of IO needed


I tried several other methods that came up with 'load_file' not defined and etc...


Anyway I hope somebody can help me! ;9

Falcon

It's not that easy, the save and load methods must be saved, and then loaded in the exact same order.

Ultimaodin

Hey thanks man I got it sorted now!

I'm using this:

module Switch_Load
  def self.load_switches
    if FileTest.exist?("Save1.rxdata")
      file = File.open("Save1.rxdata", "r")
    else
      return
    end
    # Read character data for drawing save file
    junk_characters = Marshal.load(file)
    # Read frame count for measuring play time
    junk_frame_count = Marshal.load(file)
    # Read each type of game object
    junk_system        = Marshal.load(file)
    $game_switches      = Marshal.load(file)
    file.close
  end
end


...and calling it with this:

Switch_Load.load_switches



Brewmeister helped with this. :blizj:


Thank you so much though, I thought this would have been a simple thing but i was wrong! I didn't undertand what Marshal ment in scripts. ^_^