ID:264397
 
Code:
mob
proc
save()
var/savefile/F = new("Saves/[usr.ckey].sav")
sleep(1)
F["name"] << usr.name
F["iconstate"] << usr.icon_state
F["previcon"] << usr.previcon
F["firelvl"] << usr.firelvl
F["waterlvl"] << usr.waterlvl
F["earthlvl"] << usr.earthlvl
F["airlvl"] << usr.airlvl
F["fireexp"] << usr.fireexp
F["waterexp"] << usr.waterexp
F["earthexp"] << usr.earthexp
F["airexp"] << usr.airexp
F["firemexp"] << usr.firemexp
F["watermexp"] << usr.watermexp
F["earthmexp"] << usr.earthmexp
F["airmexp"] << usr.airmexp
F["hp"] << usr.hp
F["mhp"] << usr.mhp
F["mp"] << usr.mp
F["mmp"] << usr.mmp
F["completedquests"] << usr.completedquests
F["items"] << usr.contents
F["gold"] << usr.gold
F["itembank"] << usr.itembank
F["goldbank"] << usr.goldbank
F["x"] << usr.x
F["y"] << usr.y
F["z"] << usr.z
F["icon"] << usr.icon
Write(F)
usr<<"Saved"
sleep(1200)
usr.save()


Problem description:
When I Chose to load the game, most of the vars return as null, not 0. I looked at the savefile via savefile editor and it turns out the vars that are returning null aren't being saved to the file.. any1 have any ideas??
Change all those usrs to src.

Why are you saving variables like that AND using Write()? Write() automatically saves all non-tmp blah blah variables. Look it up in the reference.

Also just to clarify, I'm assuming you're actually calling that proc somewhere.
In response to Kaiochao
Yes i am calling the proc... (had to double check tht lol.. would have been sily if i hadnt lol)

I noticed in the reference any vars tht are equal to their initial value are skipped... Thts why they werent saving... but i finally got around it.. thnx.
In response to Kozar's friend
There's no point in saving a variable that will have the same value as the default value. Those skipped variables will save only if their values are different from the default. Dream Maker does so, to conserve space.

mob/var/health = 100

/*
If a mob's health never changes from that 100, then Dream Maker will not
save the variable.

However, if the mob's health is something like 99 or 101, then Dream Maker
will save the variable.

When the mob is loaded, any non-saved variables will be given their default
value. In this case, health will be 100 if it is not saved.
*/


Therefore there is no reason to "forcefully" save variables that are skipped when being saved.
In response to Spunky_Girl
Its actually a good alternative to the default BYOND write proc.

Its used in Bleach Eternity and GOA and offers customizabilty and other features such as preloading characters before you load so you can see a preview.

Very nice when used correctly. But only the standard and necessary variables should be written otherwise the save file would probably be unusually large.
In response to DemonicK
The way I see it, there is no excuse to "manually" save each and every variable. And GOA & Bleach Eternity are prime examples of why not to do that.

If you do not want a variable to save, use 'tmp' (temporary).

You can use a simple savefile check to see if a variable saved and what value it saved exactly.
In response to Spunky_Girl
All tht in mind, i tried using that at the beginning but i wasnt getting the ariables to be set to default on the load, propably because i was calling them from the file.. ill try without in future.. might make it a bit easier for meh :)