ID:172800
 
For my new ff7 game I have chocobos that you can buy, but then I thought why not let the player buy chocobo stables as well. All that I need that I can't seem to code would be: How do you code it to when you talk to someone your key name is assigned to a turf called "stable". There will be a lot of the same turf around so how would you get it to be assigned to one that doesnt already have someones key name on it. And then how could you get an object(the chocobo) to be teleported to your stable by using a verb?
You need a variable for the turf to keep track of the owner and one for the owner to keep track of the stable (I will also use a variable to reference stables directly).
turf/var/owner
mob/var
list/stable_loc //this will list the coordinates of the stable like so: stable_loc=list(x,y,z)
turf/stable/stable


You will want a way to claim a stable as well (obviously). For this example I will use a simple claiming verb.
turf/stable
verb/Claim_Me()
set src in view(1)
if(owner)
src<<"Sorry, I'm taken"
else
owner=usr.key
usr.stable_loc=list(x,y,z)
usr.stable=src

You will also want someones stable variable to be reset when they enter back into the world, the variable will not stay referencing the turf indefinately. That is where the stable_loc variable comes into play. To get the stable turf, you will need to get ahold of the coordinates in the stable_loc.
if(stable_loc.len)
stable=locate(stable_loc[1],stable_loc[2],stable_loc[3])

When you want to put the animal back, just move it.
chocobo.loc=stable

If you want to dissalow others from entering the stable, then just do it in the stable's Enter().
turf/stable/Enter(atom/A)
if(ismob(A))
if(owner==A:key)
.=..()
else
.=0
else
.=..()
In response to Loduwijk
I couldn't get that to work but how would you get just to have your name assigned to a turf when you talk to it and then how would you get mob/NPC/chocobo that your key name is assigned to be teleported to the turf with your name. And a code I can put in my chocobo code under the "Talk" verb that would assign your key name to it.