ID:142320
 
Code:
turf
Door_Mats
icon = 'Turfs.dmi'
icon_state = "Door Mat"
var/Distance = 5
proc/Entah()
..()
for(var/obj/door/d in oview(src.Distance))
d.toggle()

Door_Click
icon = 'Turfs.dmi'
icon_state = "Door Mat"
Entered()
..()
for(var/turf/Door_Mats/d in oview(5))
d.Entah()

obj
icon='Icons/Turfs.dmi'

door
var/opening
name="Door"
density=1
proc/toggle()
if(opening)return
opening=1
if(icon_state=="open")
flick("closing",src)
density=1
sleep(times)
icon_state=""
else if(!icon_state)
flick("opening",src)
sleep(times)
density=0
icon_state="open"
opening=0


Problem description:
The code does what I want it to perfectly, when I step on Door_Click, any Door_Mat within 5 spaces does its proc, which opens the doors nearby it. The problem with the code is, when I step on the pad, it won't allow me onto the square, though it'll start to open doors. I can walk around, and once the doors are opened, it teleports me to the square. I understand that this is because it's doing the procedure before the moving, but I need to know a way so it moves me THEN initiates the procedure.
Ungh. No put usr in proc (oview() call).
In response to Kaioken
Ok lummox.
In response to Kaioken
usr is no where in that entire code segment. Though I'd appreciate it if you'd help me with my problem.
In response to Michael3131
Michael3131 wrote:
usr is no where in that entire code segment.

Had you paid attention to my post, you'd have known where to look. Turns out, you haven't. Too bad for you.

Though I'd appreciate it if you'd help me with my problem.

I'd consider fixing your code to be proper the first step. Perhaps you don't.
In response to Kaioken
Sorry, didn't see what you meant. x.x

I still don't quite get what you mean by usr at the oview() call. You aren't talking about the src.Distance are you?
In response to Michael3131
Oview Proc
Format:
oview(Dist,Center=usr)

Returns:
A list of visible objects within Dist tiles of Center, excluding Center.

Args:
Dist: A number.
Center: An object on the map.

This instruction is just like view() except it doesn't include Center or its contents in the list.
Example:
oview() << "to others in sight of [usr]"
In response to A.T.H.K
Yes, but in this case, would the 'usr' in the oview() call for the Door_Mat be the Door_Mat? If not, it still works. :P

I just have that terrible movement delay. D:
In response to Michael3131
Michael3131 wrote:
Yes, but in this case, would the 'usr' in the oview() call for the Door_Mat be the Door_Mat? If not, it still works. :P

It doesn't even matter if you think it works or it really currently works, to be honest. It's simply wrong.

I just have that terrible movement delay. D:

Your problem described in your first post didn't make much sense to me. Anyway, I wouldn't know what to say except it's your sleep() use, but that seems almost too obvious to even mention, since ideally I'd assume you actually did take a look in your code before posting. Since the density doesn't change to 0 until the proc finished waiting, you can't enter until then.
In response to Kaioken
Allow me to 'clarify' for you then? When I step onto the Door_Click turf, before my movement onto the Door_Click turf is allowed, the Door_Click turf proceedes to initiate the procedure. While the procedure, opening doors, is in effect, I can move around ANY WHERE without any problems. Once the procedure has finished, I am warped unto Door_Click. The problem is, wait, let me paste what I said earlier in my first post..:

I understand that this is because it's (The Door_Click Entered() procedure) doing the procedure before the moving (Of the mob onto Door_Click), but I need to know a way so it moves me (The mob onto Door_Click) THEN initiates the procedure. (Being the Entah() proc on Door_Mats.)

If there's anything else I can say to make it clear that opening doors IS NOT the problem, and the problem is that THE MOB is NOT allowed into the Door_Click space UNTIL the ENTAH() procedure is FINISHED, then PLEASE, let me know. I'll retype everything I've said, then maybe you won't explain to me how other sections of the code are wrong, though they work JUST fine.
In response to Michael3131
Michael3131 wrote:
[...] While the procedure, opening doors, is in effect, I can move around ANY WHERE without any problems. Once the procedure has finished, I am warped unto Door_Click.

Again this makes no sense to me. Maybe I'm blind today (and was yesterday as well), but I read your code multiples times and I don't see anything that would cause warping or moving at all (I don't see a definition of the times var either, while I'm at it).

I understand that this is because it's (The Door_Click Entered() procedure) doing the procedure before the moving (Of the mob onto Door_Click), but I need to know a way so it moves me (The mob onto Door_Click) THEN initiates the procedure. (Being the Entah() proc on Door_Mats.)

What? Then you understand wrong...?
Entered() is only called after the mob/obj has already entered the turf. In Entered(), the argument's loc equals src.

If there's anything else I can say to make it clear that opening doors IS NOT the problem, and the problem is that THE MOB is NOT allowed into the Door_Click space UNTIL the ENTAH() procedure is FINISHED, then PLEASE, let me know.

But, wouldn't that be because the Entah() proc <small>(BTW, you really shouldn't be spreading useless procs around like that. Just make Door_Click/Entered() handle activation of doors close to it)</small> doesn't finish until the toggle() proc has finished, which in turn doesn't finish until the sleep() proc has finished (and the density is only set to 0 after sleeping meaning you can only enter the location after the sleep), now?
It doesn't look like you even paid attention to my previous post before replying, sheesh.

I'll retype everything I've said, then maybe you won't explain to me how other sections of the code are wrong,

There's just a little thing I'd like to mention here: don't simply dismiss what I say, since I'm quite sure I know what I'm talking about. Thank you. :)

though they work JUST fine.

For the time being. And like I said, that doesn't mean they're not made in a wrong way.
In response to Michael3131
Michael3131 wrote:
When I step onto the Door_Click turf, before my movement onto the Door_Click turf is allowed, the Door_Click turf proceedes to initiate the procedure. While the procedure, opening doors, is in effect, I can move around ANY WHERE without any problems. Once the procedure has finished, I am warped unto Door_Click.

I don't see why Entered() would halt movement while waiting for a return value, but spawn() will allow you to call a proc without the caller having to wait for a return value.
mob/verb/spawning_test()
spawn()
src << myProcThatTakesSomeTime() // Not waiting for this proc.
src << myProcThatsQuick()

proc
myProcThatTakesSomeTime()
sleep(30)
return "It's been about three seconds."
myProcThatsQuick()
return "Wow! That was quick."