Does anyone know how I could make it so that when a person clicks on a turf if it is ocupied it will do nothing because the way I have it at the moment the character jumps around the mob trying to get to the turf.
Thanks for any help.
ID:176765
Dec 13 2002, 10:04 am
|
|
In response to Hanns
|
|
Hanns wrote:
turf/Click() Actually that won't work, because src is the turf, but src.loc is the area it belongs to. That'll go through every turf, obj, and mob in the area, so it's almost certain to return prematurely no matter what. You should change src.loc to just src there. It also couldn't hurt to bail out if src.density is 1. Lummox JR |
In response to Lummox JR
|
|
Ah. Hm, I try to code on the fly, I guess, and I admit to still stinking at it abit. *think think think think* Drawing a blank. O.o
[EDIT] Also, I typed that up on a School computer, so naturally, I couldn't test it.. |
Lucky for us, there is a proc that, when called, will return 1 if you can enter, and 0 if you can't! How wonderful! (NOTE: this isn't sarcasm =P ). All you need to do is call if(turf.Enter(usr)). This will run through all the default routines that are defaultly called when you try to enter a turf using the movement keys. It is, of course, not restricted to being next to you, so it is VERY useful for checking for any blockages on the turf.
|
In response to Hanns
|
|
Can you give me an example of how to use this
(turf.Enter(usr)) thing please. Thanks |
In response to ShadowBlade6300
|
|
ShadowBlade6300 wrote:
Can you give me an example of how to use this You're responding to the wrong post there. What Garthor meant was that the default Enter() proc for a turf checks to see first if you are dense; then, if the turf is dense, or if anything dense is already on it. If you're not dense, or the turf isn't dense and has nothing dense there, Enter() returns 1; otherwise 0. You'd call it as Enter(usr) because this would be from within Click(), where usr is the person who's clicking. Enter() takes one argument, which is the thing checking if it can enter the turf: turf Lummox JR |
In response to Lummox JR
|
|
This has the added advantage of also allowing for special conditions, like doors that you can't go through, but someone else could.
|
for(var/atom/A in src.loc)
if(A.density == 1)
return // Basically, end the thingamabob, doing zilch.
There's a little example.