Enter()
spawn()
var/obj/walk/L
for(L in usr)
if(!L)
usr<< "Your not allowed here"
return 0
if(L)
usr << "Found the key,"
if(L.active)
usr << "And it seems active."
var/tmp/drain = rand(11)
var/tmp/con=usr.control
var/tmp/drain2 = 10/con
drain += drain2
usr.Chakra -= drain
if(usr.Chakra<=0)
usr.die("drowned")
..()
return
else return 0
Problem description:
Ok, ignore the spawn() thing. What I'm trying to do is code something, so your not allowed into a turn, unless you have a certain object, for instance, a key. Then, this key has to be active, and on. So the obj has a variable for being on. My code above checks to see if you have the required object, and then SHOULD check if the variable is set accordingly. I have outputs set, to tell me how far it gets. but I'm having a problem. When I run it, and try to enter, with the object active, all it does is output "Found the key," but it doesn't allow me to enter the turf. I'd really like some help on this code. Thank you in advance.
Second, you should not have a for() loop here. Instead, you should be using locate(), so:
Third, declaring variables local to a proc as tmp do nothing. tmp is only relevant for variables belonging to an object of some sort, and makes those variables not get saved in a savefile.
Fourth, you are calling ..() but not returning its value. Instead, you just have an empty return statement, which will return null, which will forbid entry.
Finally, Enter() should never actually DO anything. It should ONLY verify whether a movable can enter an atom. You'd want to use Entered() to do something once you've entered a turf.
Oh, right, almost forgot: I'm not going to ignore that spawn(). Why the hell is it there? It REALLY shouldn't be there. Like, REALLY really.