ID:149193
Jun 19 2002, 1:11 pm
|
|
How would you make stoplights and an area that if the light is red u can't pass?
|
FireEmblem wrote:
How would you make stoplights and an area that if the light is red u can't pass? Perhaps try something like this: mob/Move(atom/newloc) This ignores any 'light' objects, but you could just have them call loc.loc.ToggleLight(the .loc of a turf is almost always an area, unless you delete it. Im not even sure if its replaced by a default /area/ if you do, so.) Alathon\\ |
In response to Alathon
|
|
mob/Move(atom/newloc) This looks good, though I'd probably override area/Enter() instead of putting the check in mob/Move, since Enter() is specifically for checking whether the area can be entered. (As opposed to Entered(), which checks whether the area really was entered.) Like so: area/trafficBoundary Enter(mob/M) if(light == RED) return 0 return ..() Of course, for an intersection (which is usually where you'd find lights), you only want to block traffic coming from one direction. You could do this by adding this code: East //Subtype that faces east (blocks westbound traffic) dir = EAST //(And so on for the other directions...) And alter Enter() to look like this: Enter(mob/M) if(light == RED) if(dir == turn(M.dir, 180)) return 0 return ..() If you really wanted to get fancy, you could stymie would-be diagonal movers by adding checks for turn(M.dir, 135) and turn(M.dir, -135). |
In response to Crispy
|
|
Where did you come from? All of sudden, a good programmer comes out of nowhere?
|
In response to Sariat
|
|
Who? Me? A good programmer? Don't you mean someone else? :P
(Who were you talking about anyway?) |
This is very rough, I haven't tried it out so I hope it works. :)