Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Load switches with script event command

Alright I hit a small bump:

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

I tried this as a call script:

Code:
$game_switches = load(1)

which came up with the error:

Cannot convert fixnum into string.


I then tried:

Code:
$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!http://i99.photobucket.com/albums/l283/ultimaodin/whistle.gif[/img]
 
If you look at the "read_save_data" method from "Scene_Load", you'll see that it uses Marshal.load multiple times on the same file. So you'll need to open the file, then load everything up to the switch data into temporary variables...

Code:
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

Then call it with Switch_Load.load_switches
 
Wow I didn't realise it would take that much just to load the switches!

Thank's mate your a freakin' legend! :thumb:

This scripting thing really has me lost, I can work out window-screens and such but I have no clue how you figured that out!

I will definatly credit you!

Oh and just out of curiosity because I really am trying to learn scripting, if I were to load an entire file from an event would that mean I'd have to do this with every aspect? eg variables, map etc...
...or is there an easier way. I'm totally confused about RGSS!

(Maybe I need to hire a scripter)

Anyway thank's a heap and if you ever need anything in return just holla. (just not sure what)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top