ID:1762801
 
(See the best response by Nadrew.)
Code:

var/tmp/list/old_card_version = list("/card/monster/LOB/blue_eyes_white_dragon")


datum/Read(savefile/F)
for(var/A in old_card_version)
if(A == F[A])
F[A] << null
src << "A card was deleted from the old savefile"

..()


Problem description:
So I know your proberbly tired of me of asking this question all the time. But this time I beleive I am onto something. All I want the code to do is before the default Read() occur is to delete anything that matches in the old_card_version list. How would I do that? I have an example that doesn't work above, am I close or am I failing so hard?
Depends entirely how you're saving things, since you're using Read() I'd imagine you're falling back to the old process that results in Write() being called.

In that case you'd have to navigate the savefile directories using savefile.dir and savefile.cd, then you can use savefile.dir.Remove(data) to cut the data.

If you need to know the format of your save so you can properly navigate it code-wise, you can run ExportText() on it (see the reference) to get a plain-text output.
Okay this will sound lazy to you but I don't get save files, I've read multiple tutorials on this topic and still none of them help. Lummox JR did show me the basics and I was able to code a basic save and load feature. But it didn't help with what I need to do. Originally this was the Read and Write Code which is basically Gathor's
proc
//proc to make a hash from a text string, end-user should override to be unique
make_hash(var/text)
return md5("[world.hub_password][text]")

//saves the savefile F in a safe format under the specified name. Safe savefile is returned.
Write(var/savefile/F, var/name)
var/savefile/F2 = new(name)
F2["file"] << F
var/hash = make_hash(F2.ExportText("file"))
F2["hash"] << hash
return F2

//loads a savefile saved using safe_save. Readable savefile is returned.
Read(var/savefile/F)
//ensure that we have a file where we say we do
var/text = F.ExportText("file")
if(copytext(text,1,14) != ". = filedata(")
return null

//grab the savefile
var/savefile/F2 = new(F["file"])
//check its md5
var/check = F.ExportText("hash")
var/hash = make_hash(text)
if(check != {". = "[hash]"\n"})
return null

//file passes the check, so return it
return F2


Now even if I modify the slitist code, it doesn't work.

This is the new code I have done after the tutorial and it works fine.
#define SAVEFILE_VERSION 1

datum/var/tmp/savefile_version // you don't need to load this--make it /tmp
datum/var/tmp/list/old_card_version = new()

datum/Write(savefile/F)

F["savefile_version"] << SAVEFILE_VERSION
..()

datum/Read(savefile/F)
..()


But I don't know how to get all typesof /card that has been written to the savefile and actually check if the typeof /card is still in the game. If its not, I want it gone. I have been doing this code for weeks now, and someone told that it should have only taken a small amount of my time. Now I understand that coding needs to be looked again and again but I have looked over it over 100 times, re done over 50 times and still I get the same result.

So please, can you explain to me what I have to do. I'm not lazy, I am confused as I do not know what to do.

Thank you.
Are you just wanting to edit the contents of a savefile or are you just trying to get your savefile system to work? I'm not understanding what you "truly" want.
Edit Contents
Best response
You could, potentially, ExportText() the savefile, then replace the old types with the new ones using a replacetext() (there's a few out there, my StringHandler library has one), then ImportText() the results.

I wrote a little patch tool for SilkWizard that he uses on NEStalgia savefiles when he needs to do things like this that works like this so I know the method works.

I do recommend backing up all of the files beforehand in case something hiccups in the process and you end up corrupting the file or breaking it.

If you can't figure this out on your own, drop me a message on the pager and I'll give you some one-on-one help.
Exactly what Nadrew said. There are save file editors out there. I have one in my utility project. If you want it, let me know. It's really easy to edit savefiles. If nothing is encrypted, then you can just CTRL+H (or whatever your replace command is) and replace all instances of what you want to replace.