ID:1341790
 
(See the best response by Neimo.)
Code:
s["mob"] << src.mob


Problem description:
runtime error: bad output
proc name: save proc (/client/proc/save_proc)
source file: Saving System.dm,19
usr: Kitty (/mob)
src: Spunky_Girl (/client)
call stack:
Spunky_Girl (/client): save proc(1)
Spunky_Girl (/client): save now()

This error appears whenever I save my mob for the first time. But after the first time, it works fine. The error points to the line of code I provided, which is weird. I use the exact same saving method in all of my projects and this is the first one to give me this error.

What exactly can cause this error? If you guys give me some examples I can look through my code to find out what is going on that is different from my other sources.
I've had bad experiences with saving a mob to a savefile, and I've never really succeeded in doing it properly, just like that.

However, Ter13 wrote a pretty good tutorial that I followed regarding saving, you can find that here. Read through both posts =)
Best response
Saving a mob is rather easy and isn't hard to do at all with proper guidance.

mob
Read(var/savefile/f)
..()
// this will get the x, y, and z from the savefile and send them there
loc = locate(f["x"], f["y"], f["z"])

Write(var/savefile/f)
..()
// store the x, y, z
f["x"] << x
f["y"] << y
f["z"] << z
// remove any icon data (up to you) or any unnecessary data
f.dir.Remove(/* "icon", "overlays", "underlays", "contents", "verbs" */)

client/proc
save()
var/savefile/f = new("[src.key].sav")
// store the mob here, it saves all variables that have been modified
f["header"] << src.mob.name // just leave this!
f["mob"] << src.mob

load()
if(fexists("[src.key].sav"))
var/savefile/f = new("[src.key].sav")
f["mob"] >> src.mob
In response to Neimo
You misinterpreted what I meant when I said "give me some examples". I did not want anyone to give me examples of saving methods. I wanted people to give me examples of what would cause this error when saving a mob to a savefile. I don't know why people are trying to vote your post up when it's irrelevant to my original post.

Besides, that method is basically exactly what I have and have been using for the past couple of years when it came to saving mobs.
Give clearing your cache a try. As crazy as it sounds, it may work.
In response to LordAndrew
Clearing my cache did work, but after saving and reloading the world and saving again, it gave me the error on first execution again.
In response to Spunky_Girl
Ah. Hrm. In my experience the "bad output" error cropped up when I saved a bad resource (in my case it was icon files opened as an environment in Dream Maker). Something having to do with it being stored in the byond.rsc would break the savefile mechanism for some unknown reason.
I discovered what was causing the problem. I had a global associative list variable to reference a bunch of icons.
var/list/skin_tones = list("Male Tan" = 'male tan.dmi',\
"Female Tan" = 'female tan.dmi')


However, since I need to access these icons during runtime without including them with .dmb and .rsc files for hosting, I thought this was the only way possible to accomplish this.

EDIT
It appears that doing this seems to corrupt something somewhere because now it refuses go away.

I also went back and opened one of my older projects that uses the exact same method of saving mobs to savefiles. It too uses an associate list to hold references to icon files. However, unlike my issue here, this "bad out" runtime error does not occur in my older project. Why is this?
Okay I updated to the latest build (1201) and it seems to have fixed the problem. I'm not entirely sure why anything ended up corrupting and causing this problem, but it's gone now. I will post back here it pops up again.