ID:139340
 
Heya all, so i wasn't sure which topic to stick this in since its both a how-to and sort of a problem at the same time. so i figure i might aswell post it here if im in the wrong zone you can all spank me later. NOTE the DEBUG texts in the codes for problem areas.

i currently use.
#define savedir "Saves/[copytext(ckey,1,2)]/[ckey].sav"
#define savedirtxt "Saves/[copytext(ckey,1,2)]/[ckey].txt"

mob/proc/Save()
var/txtfile = file(savedirtxt)
var/savefile/F = new(savedir)
src.icon = null
src.overlays = null

key = null //DEBUG -- I need to remove the key from the save file
// so that when i use the save file (it gets read) it doesn't muck with my system.
// it needs to turn the savefile into an additional mob (3 to be exact) for displaying.
// but i want the player to still be able to play on. but when key goes null we all know what happens..
// WHAMMY disconnection which is an obvious reaction i knew it before i even typed it but other attempts failed.

F["Slot[src.player_slot]"] << src
fdel(txtfile)
F.ExportText("/",txtfile)
src.Builder_Player()

so pretty much using the code above i need to be able to change the directory of the save preferably using F.cd and i need to navigate to "key" then remove it - AFTER all the rest has been saved in. that way - heres hoping- players can play on after clickin the verb that links directly to that proc and not be disconnected.

also i need it to delete the location or w.e so its not on the map while it gets outputted (as it does atm)

because as it stands currently it creates the mob in the same location as usual things (as expected) but currently does not delete them/move them outta a view range so others may be confused by it.


Further code snips for reference.
mob
proc
login_previews()
src << "Vaaaa"
if(fexists(savedir))
var/savefile/F = new(savedir)
var/mob/slotone
F["/Slot1"] >> slotone
src << "[slotone.name]"
slotone.Builder_Player() //this just makes the char with vars instead of savin info.

src << output(slotone, "login_preview1:2,2")
// the above code is the reason i need to remove key.
//and heres a cut of my save file using the current proc in the first dm tags.

Slot1 = object(".0")
.0
type = /mob/human/player
savefile_version = 1
player_slot = 1
player_active = 1
strength = object(".0")
.0
type = /statpad
baselevel = 1
expcurrent = 0
expneeded = 50
dexterity = object(".0")
.0
type = /statpad
baselevel = 1
expcurrent = 0
expneeded = 50
control = object(".0")
.0
type = /statpad
baselevel = 1
expcurrent = 0
expneeded = 50
unknown = object(".0")
.0
type = /statpad
baselevel = 1
expcurrent = 0
expneeded = 50
stamina = object(".0")
.0
type = /valuepad
baselevel = 10
expcurrent = 0
expneeded = 100
maximum = 100
current = 100
mana = object(".0")
.0
type = /valuepad
baselevel = 10
expcurrent = 0
expneeded = 100
maximum = 100
current = 100
holder_obj1 = list()
equipment = list()
banked = list()
skills = list()
skills2 = list()
name = "Dsdsdsdsd"
SavedX = 9
SavedY = 9
SavedZ = 2


i think i supplied enough information to try get a solution. if not just post and ill supply any needed info.


Ive had no luck with using cd so far to the ends that i need them after quite afew different attempts. knowing me its prolly something simple, id prefer to use the simple and clean f << src method of saving as its cleaner as opposed to the currently popular f << "mana", f << "hp etc etc.

i guess the most effective way is if i can get the reading of the savefile to work properly is to just pull the vars needed and export them to a new mob as opposed to loading the entire mob. and then just dump the mobs in a zone.. but then ill need some way to delete those mobs so there not causing unneeded clutter..

or i could try make an "image" of everything of slotone (the mob preview) and just display that. but im having no luck with that either =\

Need thoughts

Thanks in Advance.
~Midget
Fro changing the key to null, I'm not 100% on this, and I can't seem to find the page that mentions it, but I think you can change the key in the savefile by using F["key"]=null.
In response to Bravo1
Arr yea i tried that before. but i was trying to put it in the proc itself, i put it inside the read/write procs and that made it work perfectly.

Now i just help on the other area =\
In response to Midgetbuster
If the mobs that you want gone are showing up in the same loc then you could always try finding it with for(var/mob/m in view([whatever view you want])). Then find out if it's a client, if not it makes it's icon=null? not sure exactly but it's all I can suggest based on my understanding of it.
In response to Bravo1
only problem is i need their icon to be there so i can output it to a grid on login screen.. need to be able to either just read the required data to build an image of it or something similar. if it loads at all like it does it creates the mob as if it was a normal player and as such can confuse others.. need to just build the image of that person and delete it
In response to Midgetbuster
add it to the grid and then set its loc to null. It'll still shows up in the grid because the garbage collection won't delete it until it's not referenced by another variable. That may work.
In response to Bravo1
That doesn't work as soon as loc is nulled it gets removed. its direct reference and holder soon as it goes so to does that image.

Thats why im trying to make an "image" of it but so far to no luck. that way the image itself will carry on and i wont need to do anything additional..
In response to Midgetbuster
Hmm, Oh, try adding the mob to your contents. If it's in another mob then it won't be displayed on the map but you will be able to display it in a grid, I believe. works with objects which aren't very much different.
In response to Bravo1
wow, tbh i wasn't expecting that to work. but it works a charm.. The mob isn't on the map.. The mob is stored away nicely in the contents of a new mob called "logging" which is the default on login. and when they load its deleted.

So technically that should work fine in all aspects if anyone else has something to say on the matter go for gold, but this solution works for now.

It -shouldn't- make any rollback bugs.. but we shall see in the long run i guess