ID:144525
 
Code:
Alright Steven, here it is, you shouldnt have to mess with the Bump proc... Unless you see that the stacking problem is in the Bump proc, but it probably isnt...
mob/proc
Save() // This is the proc that saves the player
if(src.Savable)
var/savefile/F = new("Save/[src.ckey]") // This creates a new file called your key.sav in the file Save
F["last_x"] << src.x// This stuff saves the players location
F["last_y"] << src.y
F["last_z"] << src.z
Write(F) // This Writes the file
Load()
if(fexists("Save/[src.ckey]")) // This checks if they player has a savfile
var/savefile/F = new("Save/[src.ckey]")
Read(F) // This reads the file!
F["last_x"] >> src.x
F["last_y"] >> src.y
F["last_z"] >> src.z
else
alert("You do not have any characters on this server.")
usr.Choose_Login()


Problem description:

The Load() proc needs work. It has usr abuse, and also it's trying to load to x,y,z directly when it should be loading to local vars and then using locate().

Lummox JR
In response to Lummox JR
What is the best way not to use usr in a proc?

I'm bad at "abusing" usr in procs but only because I don't understand how not to use it.
In response to KirbyAllStar
use src instead
In response to Shlaklava
if you use src in an obj proc then it doesn't work with mob variables
In response to KirbyAllStar
KirbyAllStar wrote:
What is the best way not to use usr in a proc?

I'm bad at "abusing" usr in procs but only because I don't understand how not to use it.

The way not to use it is not to use it. Pretend it doesn't exist if you're in a proc.

The next step is the most important--you have to think around this obstacle. Obviously if you don't have usr available, then you have to make do with the information the proc already has. Is that information enough? Is an existing var like src the right choice, or does the proc need to be sent more information?

Lummox JR
In response to Shlaklava
Shlaklava wrote:
use src instead

While sometimes src is the right answer, it is not necessarily so. The right thing to use depends a lot on the context. Just because usr is wrong does not necessarily mean that src is right.

Lummox JR