Savegames
There are many things that people find hard to make, and many things are hard to make. However, Savegames isn't one of them, despite what most people think. I've written this little guide to show you a way to make a savegame system quickly and easily. However, at least some basic knowledge of Verge C code is required.
ReadVars() en WriteVars():
The developers of Verge built these functions to make creating saving systems hella easy. However, they don't always work properly, crashing whenever you use global file pointers. I don't recommend them, since global file pointers are much more useful than these functions. Why? Because there's a good workaround for these functions.
First some basics: File management
There are several functions that are necessary to prepare the files for writing and reading. These are fOpen, fClose, fWOpen and fWClose. These functions respectively open a file for reading, close a file for reading, open a file for writing and close a file for writing. They are used like this:
pointertothesavefile = fOpen("savefile.sav");
fClose(pointertothesavefile);
fWOpen and fWClose are necessary for the saving script, while fOpen and fClose are necessary for the loading script. fDelete may alse be useful (it deletes files) but beware that fDeleted file are not backed up in any way!
The pointertothesavefile var is very important, because it's needed to use any writing functions whatsoever.
Writing and Reading integers to/from a file
Okay, you want to save some hit points in your opened save file. How do we do that? Well, first of all we must open a file for writing with the fWOpen function. The next thing we need to do is to actually write the integer. This is done like this:
fwritestring(str(nameoftheinteger), pointertothesavefile);
The integer will be written the way it is, no encoding or anything. After the integer a block will be written to divide the different pieces (these pieces are called 'tokens'). So why the str(...) thingy? Well, you can't write integers in files unless you convert them to strings first, and that is exactly what this function does. I could've put it seperately, but it would take more coding without making it much clearer. Just remember that you'll have to use str(...) when writing an integer.

So much for the saving part, let's get on to loading! So how is this done? Well, again we need to open the save file, but this time with fOpen because we are going to read from it (instead of writing to it). So how goes the actual reading? Like this:
fgettoken(nameoftemporarystring, pointertothesavefile); nameoftheinteger=val(nameoftemporarystring);
'nameoftheinteger' is the name of the integer that will receive the new value. The val(...) thingy is the reverse of str(...). It converts strings back to integers, which is necessary for calculating with it and the like. This may seem a little easy right now, but there is one thing that is important when reading and writing tokes:
You must read all the variables in exactly the same order as you have written them!!!!
If the order is even only one position off, your loading will be severely screwed and Verge will likely crash. I therefore suggest double or even triple checking the order.
Writing and Reading strings to/from a file
Writing and reading strings is quite similar to writing and reading integers, except for a few things:
-You should not use the str(...) and val(...) functions on strings. Those are only needed for integers. Using them on strings will give errors and other ugly unexpected stuff.
-Don't use spaces or underscores in your strings. These are interpreted as token endings, which will result in unpredictable things and many errors. There are also a few other 'nono' characters, but I can assure you that the "-" is not one of them. If you like to save a string with spaces I suggest using the "-" instead and modifying the in-game font so that the "-" will be displayed as a space.

Final Comments:

-When you've loaded a game, you may want to teleport someone to the right map. This can be done (of course) by using the Map(...) function. However, I cannot stress it enough, since this caused my project a 2 month delay: PUT THE MAP FUNCTION AT THE END OF YOUR FUNCTION!!!
-I've cut and pasted the savegame code from The Shiny Sword. It's shortened and modified to keep it clear, but it contains enough variation to be useful. Some of the variable names may make little sense. Don't be too harsh on me, it's just a bad habit of mine (I remember typing "int peanut;" once..). Important: this code is made for Verge 2k+j. It is compatible with older versions(except for Verge 1 of course!), though you'll have to remove the "local", "global" and "function" stuff first.

Well, so much for my attempt at helping you. I hope this is of any use and if you have any questions or criticism, please mail me at devlyn@zonnet.nl.



//SAVE

function void Save(int slot)
{
local int nfile;
locationmap = current_map;

/* Opening Slots To Save In */

if(slot=1) // Saving In Slot 1
{
fdelete("slot1.dat");
nfile = fwopen("slot1.dat");
}
if(slot=2) // Saving In Slot 2
{
fdelete("slot2.dat");
nfile = fwopen("slot2.dat");
}

/* Save The Variables */

/*1: Flags */
for(a=0;a<8000;a++)
{ fwritestring(str(flags[a]), nfile); }

/*2: Current Map */
fwritestring(current_map, nfile); // Saving Current Map

/*3: Current Location */
fwritestring(str(entity.tx[player]), nfile);
fwritestring(str(entity.ty[player]), nfile);

fwclose(nfile);

Text(0,"Succesfully saved!","","");
}


global string ts, ndest; //temp. string!

//LOAD

function void Load(int slot)
{
local int nfile;
local string NewMap;

/* Opening Files To Load From */

if(slot=1) // Loading From Slot 1
{
nfile = fopen("slot1.dat");
}
if(slot=2) // Loading From Slot 2
{
nfile = fopen("slot2.dat");
}

/* Load The Variables */

/*1 Flags*/
for(a=0;a<8000;a++) //Loading Flag Variables!
{ fgettoken(ts, nfile); flags[a] = val(ts); }

/*2 Current Map*/
fgettoken(ts, nfile); NewMap = ts;

/*3 Current Location*/
fgettoken(ts, nfile); px=val(ts);
fgettoken(ts, nfile); py=val(ts);

fclose(nfile);
Text(0,"Succesfully Loaded!","","");

/* The next function is to teleport to the correct map: Put Map functions
ALWAYS last in your vc functions!!! This is
to prevent a fatal buggy event in Verge
from taking place. */

Map(NewMap);
}