//Selecting what slot to load
proc/Dunglasloading()
var
global/current_file
slot_list = list("Slot 1","Slot 2","Slot 3")
default_value = "Slot 1"
loaded_slot = input("Load game","What slot would you like to load?",default_value) in slot_list
switch(loaded_slot)
if("Slot 1")
usr << "Loading slot 1..."
current_file = 1
src.NewChar()
if("Slot 2")
usr << "Loading slot 2..."
current_file = 2
src.NewChar()
if("Slot 3")
usr << "Loading slot 3..."
current_file = 3
src.NewChar()
else
Dunglasloading()
//Saving the char in the right slot
Logout()
world <<"[src.ckey] has left Dunglas."
var
subfolder = copytext(usr.ckey,1,2)
savefile/F
switch(current_file) //this is the problem: var doesn't carry over from another proc
if("Slot 1") F = new("savefiles/[subfolder]/[usr.ckey]/1")
if("Slot 2") F = new("savefiles/[subfolder]/[usr.ckey]/2")
if("Slot 3") F = new("savefiles/[subfolder]/[usr.ckey]/3")
Write(F)
F["saved_x"] << usr.x
F["saved_y"] << usr.y
F["saved_z"] << usr.z
del(src)
..()
Problem description:
I am making a savefile system that consists of 3 different slots, each having its own savefile. However, I am having trouble with the variable that determines which slot is currently being played on (current_file), that is first determined on login, once the Dunglasloading proc is triggered.
The problem is that the variable current_file isn't recognized in the logout proc, which is normally used to tell the game what slot to overwrite. I turned the variable global in hopes it would help but it didn't do the job.
What you probably want instead is a client or mob variable. Here's an example of a client variable being used: