RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Load switches with script event command

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 85
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

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
It's not that easy, the save and load methods must be saved, and then loaded in the exact same order.

**
Rep:
Level 85
Hey thanks man I got it sorted now!

I'm using this:

Code: [Select]
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:

Code: [Select]
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. ^_^