ID:148538
 
This proc just wont work.

Purpose: Keep unwanted visitors out (everyone except me).

mob/proc/zlegendshouse()
if(key==!"Zlegend2")
Enter(1)
usr << "Welcome home Zlegend!"
return 1
else
Enter(0)
usr << "Stay away."
return 0

turf/zlegendshouse
usr.zlegendshouse

The proc just flat out wont work.
Zlegend2 wrote:
This proc just wont work.

Purpose: Keep unwanted visitors out (everyone except me).

mob/proc/zlegendshouse()
if(key==!"Zlegend2")
Enter(1)
usr << "Welcome home Zlegend!"
return 1
else
Enter(0)
usr << "Stay away."
return 0

turf/zlegendshouse
usr.zlegendshouse

The proc just flat out wont work.

When you call the proc it should be like this:
turf/zlegendshouse
Enter()//call the proc inside of Enter() so that it calls the proc before the mob enters the turf
src.zlegendshoue()//if you dont add the ()'s it will think zlegendshouse is a var


as for the proc itself dont use ==! as this does absolutely nothing that i can tell. Just use == .

In response to Jotdaniel
usr.zlegendshouse() (correction)

you call the proc using usr. not src. it will come up as an undefined proc.
In response to Zlegend2
Zlegend2 wrote:
usr.zlegendshouse() (correction)

you call the proc using usr. not src. it will come up as an undefined proc.

Wrong again. usr has no place in movement procs (except in rare cases). Enter() has an argument that's the atom trying to enter, and that's what you use instead.

Lummox JR
In response to Zlegend2
No, you dont use usr here. You use src. If it doesnt work its not my fault, but usr will mess you up if you use it to often becuase it doesnt work in all situations.
In response to Jotdaniel
Jotdaniel wrote:
No, you dont use usr here. You use src. If it doesnt work its not my fault, but usr will mess you up if you use it to often becuase it doesnt work in all situations.

src isn't correct either, because it's the turf. That's one reason why a lot of people mistakenly switch to usr instead.

Among other problems in the original code, a couple of the lines that make zero sense are Enter(1) and Enter(0); those aren't valid calls to Enter(), which takes an atom/movable as an argument.

Lummox JR
In response to Lummox JR
Whoops. Sorry bout that then. I guess your right. I didnt think about what src called there, i just didnt think usr was correct either.
In response to Lummox JR
mob/proc
zlegendshouse()
if(src.key!="Zlegend2")
Enter(1)
usr << "Welcome home Zlegend!"
return 1
else
Enter(0)
usr << "Stay away."
return 0

turf/zlegendshouse
Enter()
usr.zlegendshouse()

-----------------------
No matter what my key is, it always says "Stay away." even on Zlegend2.
In response to Zlegend2
thats becuase the != means if it does not equal, so of course it will always tell you that.
In response to Jotdaniel
when i put it this way:

=!"Zlegend2" it says missing expression so i have to put ==
In response to Zlegend2
Zlegend2 wrote:
No matter what my key is, it always says "Stay away." even on Zlegend2.

Well, that doesn't really surprise me, because both procs are still screwed up. You're putting usr in Enter(), which is wrong, and you're using it in the zlegendshouse() proc, which is wrong. The only time usr is really safe to use in a proc, pretty much, is if that proc is exclusively called by verbs.

Among those problems, you're also calling Enter() wrong; it's called during Move(), and with an argument corresponding to the atom that's moving (that is, your mob). Enter(1) and Enter(0) are invalid, because that's not supposed to be a number; it takes the mob (or an obj), and returns 1 if the atom can enter, 0 if it can't.

You're also not returning any value in Enter() proper, so it's always returning null which is interpreted as 0, and you'll never get in no matter what.
area/zlegendshouse
Enter(atom/movable/A)
if(ismob(A))
var/mob/M=A
if(M.client && M.client.ckey=="zlegend2)
return 1
else
M << "Stay away."
return 0
return ..() // let objs through if not dense or not blocked by something dense

Lummox JR
In response to Lummox JR
i get it! thanx again. :P about four months trying to learn DM and i still havent quite got it. But i got a blue book and im studying it sometimes.
In response to Zlegend2
Just use ==, thats the only operator that does what ya want(that i know of.)