Hello, uhm, I was just wondering if there was a way to make it so you could only enter a tile from one direction or side. What I mean is, say you had a tile
[]
And you only wanted people to enter it from the right side.
x
x [] <--
x
I'm fairly new to coding, but this would help me alot with what I'm trying to do. I know it probably has to do something with the built in Cardinal directions, NORTH, EAST, WEST, and SOUTH.
<></<also>
ID:159713
![]() Jan 23 2009, 11:38 am
|
|
![]() Jan 23 2009, 11:57 am
|
|
Thank you so much Falacy!
Can I use this to make it so one can only enter from East, South, and West? I'm using these to make a 3D feel to the North edge of a platform, so you need to be able to walk along the edge. Thanks again for the help! It's much appreciated! |
turf/SingleEntry That should allow you to limit which directions they can Exit the turf in. And yes, to change which direction/s it allows you to enter/exit from; just change where it says NORTH to whatever direction you want. If you want multiple directions available on a single turf do something like this: if(M.dir==NORTH || M.dir==SOUTH) return ..() |
Again, thank you. You're a genius. I see why Artemis holds you to such high praises. :) *If that's even a phrase? lol*
|
And another way to do the samething as in the last snippet with bit operators:
if(M.dir&3) return..() 3 is NORTH|SOUTH (1|2) >_> |
This is a more generalized method:
turf Now, for the no_enter and no_exit variables, you would set them equal to a direction flag, with the | (pipe) symbol between them. For example, if you wanted them to not be allowed to enter from the north and east, but are also not allowed to exit from the north and south, you would do this: no_enter = NORTH | EAST |
Popisfizzy wrote:
> no_enter = NORTH | EAST And then when he wants them to only be able to enter/exit from 1 direction he has to set 7 flags? |
Well, if you're completley ignorant of how bitflags work, yes. If you have some idea, though, no:
no_enter = SOUTH | EAST | WEST |
Popisfizzy wrote:
Well, if you're completley ignorant of how bitflags work, yes. If you have some idea, though, no: Yea pretty much, feel free to explain o.O |
Popisfizzy wrote:
> NORTHWEST = NORTH | WEST How is it stored though? Since that other guy said 3 represents NORTH|SOUTH since they're 1|2. |
... they're stored exactly like that. NORTHWEST = NORTH|WEST = 1|8 = 9, and if you output the value of NORTHWEST you'll get 9.
|
Popisfizzy wrote:
... they're stored exactly like that. NORTHWEST = NORTH|WEST = 1|8 = 9, and if you output the value of NORTHWEST you'll get 9. So if it stores them as a numerical total of all variables combined. How would adding more than 2 variables work? You'd end up with something like NORTH|EAST|WEST which would yield 13 o.O |
Popisfizzy wrote:
Okay, it's very obvious I'm not getting anywhere. Read this, then read the thread again. AH HOH! so its not actually a numerical value, but binary. Each bit representing a different switch in said binary. Makes sense now =P And in any value that would require 2 switches to be on, it returns as true if either is on. |