Code:
Problem description:
How would i go about and make a turf/obj/atom that can only be entered from one direction? I am trying to make single tile houses that can only be entered from one direction, one way would be by checking wether the house is in the correct direction relative to the player, but that is hard since i dont know how to check what is adjacent to something.
Help!
You could make a parent proc to handle all atoms and just have it refer to a list or bitflags of an atom. I was actually thinking about doing this myself- I'll post what I come up with later.
|
Here's something I use a lot for tile based games
turf Set the moves var to handle which directions you want to allow Example: turf/NS_tunnel //north south tunnel |
Regardless, Enter() does no movement. The movement system reads its return value in Move(). You're only returning FALSE.
|
Enter returns 1 or 0, either let them in or don't. Returning FALSE in Enter means "don't let them in". Or am I wrong?
|
Albro1 wrote:
Enter returns 1 or 0, either let them in or don't. Returning FALSE in Enter means "don't let them in". Or am I wrong? TRUE is just a compile-time constant that equates to 1, while FALSE is a compile-time constant that equates to 0. |
Would this allow me to change the directions you can enter from on the fly? As if in a guy were to lock the door?
|
Yes. Bit-shifting is pretty simple:
Turn a bit on: (or) mask |= bit Turn a bit off: (and inverse) mask &= ~bit toggle a bit: (xor) maks ^= bit If you are confused about how it works, a bit of light reading on binary math would probably do you some good. |
Albro1 wrote:
Um...I know? Oh wait... Rhetorical questions at 3:30 in the morning... You'd have thought that would have occurred to me. |
Please forgive me, and may any potential deities have mercy upon my soul for doing this, but I HAVE to make this joke...
turf Again, please forgive me. I'm not even sure that I can ever forgive myself, but the compulsion was too great. (in my defense, I had to look their names up!) |
Huh... And here I thought boy bands were something only my generation was blighted with...
|
To clarify, the statement "..()" is not a return statement. It doesn't cause anything to be returned at that line, so your code follows through to the "return FALSE" line (which isn't even necessary), regardless of what happens at the ..() line, which effectively does nothing.
The reason we want to return ..() instead of TRUE is so we bump into other dense objects that may be on the turf already. |
Oh, the boy band tradition has carried on throughout the years. Pop culture is never short of at least one omnipresent (yet horrendously awful) boy band. When one breaks up (usually due to the only member with any semblance of real talent breaking off to do his own thing, and/or puberty setting in and ruining their voices past the point that auto-tune can help), there are always a few more waiting in the wings.
Thankfully, I'm far enough removed from the current music scene that I only know of this one thanks to constant media bombardment (as per usual with every boy band; plus this one even comes with its own feature film!) and my brain's (sometimes unfortunate) ability to absorb virtually every piece of data that floats through it, welcome or not. Anyway, now that I've gotten the joke out of my system, we can all go back to pretending boy bands don't exist. |
In the Enter() proc, you can check what direction the mob that is trying to enter is facing. If it is the right direction, let them in.