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.

Call a RGSS Script from event...

Toshi

Member

Hi, i've got this script (hope its correct for saving instantly)

Code:
def save

    for i in 0..10

        sleep(0.1)

    end

    Audio.se_play(QUEST_SAVE[0], QUEST_SAVE[1], QUEST_SAVE[2])

    $game_system.newgame_switch = false

    file = File.open($game_system.save_slot, "wb")

    write_save_data(file)

    file.close

    @saved = Sprite.new

    @saved.bitmap = RPG::Cache.picture("saved")

    @saved.x = (640/2) - (@saved.bitmap.width / 2)

    @saved.y = (480/2) - (@saved.bitmap.height / 2)

    return

end

 

def write_save_data(file)

    characters = []

    for i in 0...$game_party.actors.size

        actor = $game_party.actors[i]

        characters.push([actor.character_name, actor.character_hue])

    end

    Marshal.dump(Time.new, file)

    Marshal.dump(characters, file)

    Marshal.dump(Graphics.frame_count, file)

    $game_system.save_count += 1

    $game_system.magic_number = $data_system.magic_number

    Marshal.dump($game_system, file)

    Marshal.dump($game_switches, file)

    Marshal.dump($game_variables, file)

    Marshal.dump($game_party, file)

    Marshal.dump($game_self_switches, file)

    Marshal.dump($game_screen, file)

    Marshal.dump($game_actors, file)

    Marshal.dump($game_troop, file)

    Marshal.dump($game_map, file)

    Marshal.dump($game_player, file)

end

Now i've got a nice menu wich works with events.
I want to call this posted code with the menu, can anybody help me to save instantly with "events"?
 

Toshi

Member

That worked, but it calls the save script. The game is saved but then there is the error:

"Nomethoderror occurred while running script.
undefined method 'call' for #<Interpreter:0x8c826e0>"

I've deleted all the stuff and run the game again, but I think it has saved the error msg in the sacegame, cause without the "call save()" and the script, the message still appears when I've loaded the savegame.
 

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