ID:269772
 
I think I know what to do here, but the code I first tested has som serious problems... I just want to restart it entirely. How would I write the Click() proc for a save hud button? It must save location, icon_state, variables, and overlays. Any Ideas?

--Vito
Show us what you did.
In response to N1ghtW1ng
obj
hud
Save
icon='HUD.dmi'
icon_state = "Save"
screen_loc="15,1"//when it is moved to someone's screen, it's loc is 15,1
Click()
var/savefile/F = new(usr.ckey)
F["last_x"] << usr.x
F["last_y"] << usr.y
F["last_z"] << usr.z
Write(F)
usr<<"Saving..."
sleep(20)
usr<<"Your progress has been saved."
//Writes savefile


and...

            if("Load")
var/savefile/F = new(usr.ckey)
Read(F)
var/last_x
var/last_y
var/last_z
F["last_x"] >> last_x
F["last_y"] >> last_y
F["last_z"] >> last_z
loc = locate(last_x, last_y, last_z)
usr<<"Your character has been sucessfuly loaded."
//reads savefile

And I also put it on the screen, that's the easy part.


--Vito
In response to Vito Stolidus
I'd suggest making a save and load proc first, and then make the hud button call the procs.
In response to Mecha Destroyer JD
Thanks. I have a save verb, but I can't call that.

--Vito
In response to Vito Stolidus
Uh, calling Write(F) is all fine and dandy, but you're not supposed to be saving the button (src), but the player (usr). Hence it should be usr.Write(F).

However, saving last_x/y/z here is a bad idea. You should be doing that in Write() itself, not in your HUD. The HUD button should merely be an alternative way to access save functionality.

Likewise of course, Read() should be doing more work when loading than it currently does.

Lummox JR