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.

Dumping Variable Data in Save

Well, a bug was found in a script I made, I was trying to the last hour or so to correct it but I could not figure out the solution. Basically, I need it so Global variables are saved into the .rxdata save file and then reloaded so the values reset to what it was before.

Currently, upon loading the game, the value of the Global variable sets based upon the value the script tells it.

I hope you understand what I need.

Thanks in advance, if you need more info just ask.

Syn.
 
To save a variable to a file, use:
Code:
file = File.open("filename", "w")
Marshal.dump(variable, file)

To read a variable from a save file, use:
Code:
file = File.open("filename", "r")
variable = Marshal.load(file)
 
I tried that already, but it did not save correctly. Should I add it to The Load and Save scenes or in a seperate class within my actor script?

EDIT: Got it working, thanks a lot Daniel!
 

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