Foomer helped me out with this before, but somehow it doesn't seem to be working,
here is the code I am using:
turf/barw
icon = 'barw.dmi'
density = 0
dir = WEST
Enter(atom/movable/O)
if(!O.density) return ..() // if O's not dense, ignore all this
if(O.dir == NORTH) return ..()
if(O.dir == WEST) return ..()
if(O.dir == SOUTH) return ..() // if facing north, let it through
else return 0 // else return 0, or don't let it enter.
Exit(atom/O)
if(O.density) return ..()
if (O.dir == NORTH) return ..()
if (O.dir == EAST) return ..()
if (O.dir == SOUTH) return ..()
else return 0
Now I am defining this on a turf and the Enter() conditional is working but I cant seem to get the Exit() conditional to work. I get no compile errors, however, the mob can still exit any directionfrom the square, What am I missing?
ID:179269
Jan 26 2002, 9:49 am
|
|
In response to Lummox JR
|
|
Lummox JR thankyou for showing me how to make the code more compact, although most of what you said was WAY confusing and I have no Idea how it might be applied or the syntax to use if doing so.
However in reference to my original message the section Exit(atom/O) if(O.density) return ..() should have been Exit(atom/O) if(!O.density) return ..() A single exclamation and I loose an entire day beating myself up in desparation. Thankyou all for the help. Illya |
Your code seems to be contingent on O.dir being set before it moves, which may not be the case. Part of the problem is that Enter() and Exit() should be--but aren't--given an additional argument indicating where the atom is coming from and where it's going, respectively. Without this information, you have to rely on workarounds.
I have one such workaround for you:
This should help your code work correctly.
In addition, I recommend you change your direction checks as follows:
Or, if you use the dir var to control which way the tile blocks, you can actually try this code for all similar tiles:
Lummox JR