ID:158254
 
I've always been really weak on save-files, and a several-year absence from BYOND hasn't helped!

I want it so that whenever I close the program running the world that several vars are saved to a file, and the moment I run it again they're loaded back in. It sounds simple but I'm not sure where to start!

Thanks in advance for any advice!

~Ease~
world/New
world/Del
In response to GhostAnime (#1)
How do you declare world vars?! I tried

world/var/turn


and was treated to this error message:

Vars.dm:3:error:turn :variable declaration not allowed here

How come?

<edit>I've now tried the following, but it's failing. Ungh!

world

New()
..()
var
Turn // The current turn
Phase // Current Phase, 1=Attack, 2=Defend, 3=Results
var/savefile/F = new("World")
Read(F)

Del()
..()
var/savefile/F = new("World")
Write(F)
In response to Ease (#2)
Take the world part out.

Just;

var/turn


I'm going to let you figure out how to do the saving and loading part ;)

Reference/Guide are your friends, by the way.
In response to Andre-g1 (#3)
Ah thanks Andre, that was really bugging me! Got it working now!