ID:139923
 
Didn't really want to start a new thread for awhile but i decided id go and finish up the rest of the saving and loading procs and when adding the if and else statements to check if there is a file existing and then to check if slot one (or two) is detected it detects the slot one (or slot two) but for whatever reason doesn't run the load procs.

//==First code snips are addon codes that may/may not relate to the code in question but are placed here to be sure.
Code: Code Addons
//Code Snip Addon 1
//The load proc.
client/proc/Load(var/slot)
alert("Call 1 - [slot]") // launched
var/savefile/F = new("Player Saves/[copytext(ckey,1,2)]/[ckey].sav")
alert("Call 2 - [slot]") //launched
F["Slot[slot]"] >> mob
alert("Call 3 - [slot]") //failed

//Code Snip Addon 2
//the Save code. Not sure if its needed but if it can be modded or is an ineffective failed system please advise me so i may fix the errors.
mob/logincharacter
proc
CreationPro(var/sluck)
var/mob/newchar
newchar = new/mob/human/player(locate(3,3,2))
newchar.slot = sluck
newchar.stamina = 50
newchar.created = 0
usr.client.CreationChangeProc()
usr.client.mob = newchar

verb
NewCharacter() //execute for new char
switch(alert("Please choose slot to play in","Character Creation","Slot One","Cancel","Slot Two"))
if("Slot One")
if(fexists("Player Saves/[copytext(ckey,1,2)]/[ckey].sav"))
var/savefile/F = new("Player Saves/[copytext(ckey,1,2)]/[ckey].sav")
if(F.dir.Find("Slot1"))
switch(alert("Would you like to Overwrite Slot One","Character Creation","Yes","No"))
if("Yes")
CreationPro(1)
else
return
else
alert("save but no slot one")
CreationPro(1)
else
alert("bing no save")
CreationPro(1)

if("Slot Two")
var/savefile/F = new("Player Saves/[copytext(ckey,1,2)]/[ckey].sav")
if(fexists("Player Saves/[copytext(ckey,1,2)]/[ckey].sav"))
if(F.dir.Find("Slot2"))
switch(alert("Would you like to Overwrite Slot Two","Character Creation","Yes","No"))
if("Yes")
CreationPro(2)
else
return
else
CreationPro(2)
else
CreationPro(2)

if("Cancel")
return


Code: Code in question
        LoadSlotOne() //execute to load slot one
// usr.client.LoadedChangeProc(usr.client) //executes the proc that changes all the windows to the map.
// usr.client.Load(1) //executes the load proc (see "Code Snip Addon 1") these 2 noted out commands worked perfectly before the introduction of the if/else statements.

if(fexists("Player Saves/[copytext(ckey,1,2)]/[ckey].sav"))
var/savefile/F = new("Player Saves/[copytext(ckey,1,2)]/[ckey].sav")
if(F.dir.Find("Slot1"))
alert("Ding")
usr.client.LoadedChangeProc(usr.client)
usr.client.Load(1)
else
alert("Bam")
return


Problem description: as noted above, when i added the if and else statements to the loading proc to check for the save it doesn't work (well it does half way) it launches the proc that changes the screens but does not launch the actual loading procs.

Furthermore once i figure out this problem i will prolly modify it again to do checks for slot one saves and then make it launch the commands for creating a new char so that it auto makes something in slot one if the load has none there

EDIT: Added the updated alert commands to the Code snip addon 1. as you can see it launches the first 2 but fails to run the mob launcher. it use to work fine before the introduction of the if and else in the verb =\
        LoadSlotOne() //execute to load slot one
// usr.client.LoadedChangeProc(usr.client) //executes the proc that changes all the windows to the map.
// usr.client.Load(1) //executes the load proc (see "Code Snip Addon 1") these 2 noted out commands worked perfectly before the introduction of the if/else statements.

if(fexists("Player Saves/[copytext(ckey,1,2)]/[ckey].sav"))
var/savefile/F = new("Player Saves/[copytext(ckey,1,2)]/[ckey].sav")
if(F.dir.Find("Slot1"))
alert("Ding")
usr.client.LoadedChangeProc(usr.client)
usr.client.Load(1)
else
alert("Bam")
return


Now, is your Load() proc being called at all? If not, LoadedChangeProc() may be holding it up.
In response to Teh Governator
I added an additional alert to my load proc to see if it was indeed being called.

It is being called since the alert did come up.

so my new load proc ended up being

client/proc/Load(var/slot)
alert("Call 1")
var/savefile/F = new("Player Saves/[copytext(ckey,1,2)]/[ckey].sav")
alert("Call 2")
F["Slot[slot]"] >> mob
alert("Call 3")


Results:
Call 1 Achieved.
Call 2 Achieved.
Call 3 Failure.
In response to Midgetbuster
Any run-time errors?
In response to Teh Governator
loading KHR - Flames of The Revolution.dme
loading Z. Interface.dmf
loading Z. Map.dmm
saving KHR - Flames of The Revolution.dmb (DEBUG mode)

KHR - Flames of The Revolution.dmb - 0 errors, 0 warnings


None as far as the compiler says.
client/proc/Load(var/slot)
var/mob/new_mob
var/savefile/F = new("Player Saves/[copytext(ckey,1,2)]/[ckey].sav")
F["Slot[slot]"] >> new_mob
if(new_mob)
mob=new_mob
alert("called")
In response to Teh Governator
Nope, thats a no go same thing as what i got :(
In response to Midgetbuster
Midgetbuster wrote:
Nope, thats a no go same thing as what i got :(

Ya, it's a little hard for me to really tell at this moment if everything's working the way it's supposed to as, I don' have BYOND on this computer. So, can't test-compile anything...Just working out of notepad. Now, did the save and load stuff work before your mods? Also, have you modified the Read() or Write() procs at all?
In response to Teh Governator
Yeah it all worked fine before i added those if and else statements to the click command of the loadslotone verb. as the bare window changer and load proc.

and yes there is modified read writes.

mob
Write(var/savefile/F) //writes the file pretty straight forward
..()
F.dir.Remove("icon","overlays","underlays") /*this removes the entire directory for icon,overlays and any underlays that may exist.
this is also covered in the actual save proc above but due to a DM language bug overlay and icon are prewiped before save and this cleans it*/

F["SavedX"] << x
F["SavedY"] << y
F["SavedZ"] << z

Read(var/savefile/F)
..()
usr.Base_Build()
usr.Overlay_Build()
loc = locate(F["SavedX"],F["SavedY"],F["SavedZ"])

client/proc/Save()
var/txtfile = file("Player Saves/[copytext(ckey,1,2)]/[ckey].txt")
var/savefile/F = new("Player Saves/[copytext(ckey,1,2)]/[ckey].sav")
mob.icon = null
mob.overlays = null
F["Slot[usr.slot]"] << src.mob
fdel(txtfile)
F.ExportText("/",txtfile)
mob.Base_Build()
mob.Overlay_Build()
In response to Midgetbuster
The issue is that you are using usr in procs.

Do not use usr in procs.
In response to Garthor
I know Garthor, I thought i did eliminate the usr in procs. i guess i didn't obviously.

I only picked up one usr in the procs except the usr in the usr.client stuff which i just changed to client.xxxx (if thats right)

But the problem still occurs either way.
EDIT:
Well after modding other parts of my code and adding other stuff i came to realize that my mistake was a simple " / " that wasn't originally needed but probably should have been in the first place.

Either way problem solved thanks Gov for trying to help out appreciate you atleast trying.








OLD POST:

Im not sure. I ran some more tests and what not throughout my code and it would seem even without the load proc having a var declared on the verb it still does not return the save properly.

        LoadSlotOne() //execute to load slot one
// client.LoadedChangeProc(usr.client)
// client.Load(1)
var/savefile/F = new("Player Saves/[copytext(ckey,1,2)]/[ckey].sav")
if(fexists("Player Saves/[copytext(ckey,1,2)]/[ckey].sav"))

if(F.dir.Find("Slot1"))
alert("Ding")
client.LoadedChangeProc()
client.Load()
else
alert("Bam")
return

client/proc/Load()
var/savefile/F = new("Player Saves/[copytext(ckey,1,2)]/[ckey].sav")

F["Slot1"] >> mob


without the if and else statements which im now assuming ive stuffed up greatly somehow works fine but soon as there put into play aint no loading goin on