ID:271002
 
How you make it so that when somone bumps an object such as a door a message pops up asking them if they want to enter or not and if so the icon open state flicks open and then once they have goten through the icon flicks back to closed. I looked at the dm guide but didnt understand the part that told me how to do this so can someon give me an example code.
obj
Door
icon="door.dmi"
Bump(mob/M)
if(istype(M,/mob))
src.density = 0
flick("Open",src)//flick("IconStateHere",src)
src.density = 1


That SHOULD work, I'm not sure but I think the src here would be the object.
In response to KirbyAllStar
Er, not quite...

Bump() is activated on the object that bumped INTO something, not an object that was bumped BY something...

however, to achieve that effect (calling a bump() type proc before/after an object bumps into something), you just need to modify Bump() and add in a proc or two:
atom
proc //setting up two types of bump.
preBump(atom/A) return 0
postBump(atom/A) return 0

movable/Bump(atom/A) //Here's the slight modding
A.preBump(src) //Calls A's (the object bumped INTO) preBump() proc which we defined
if(A) ..() //if A still exists, continues Bump() procedure of the object that has bumped into something
if(A) A.postBump(src) //If A still exists, it calls it's postBump() procedure


obj/Door
preBump(mob/M)
if(ismob(M)) //Shortcut fr 'if(istype(M,/mob))' ... I can also do iftype(M) which is understood to be looking for /mob,\
as that's how we defined the M variable [if I defined it as mob/player/M, istype(M) would be checking if it's /mob/player

M<<"Ouch!"


Also, flick() pretty much returns immidiately, so you have to sleep the timing in which it was called before densing it again.

To get an approximate timing done, it's: sleep( number of frames * frame delay )

- GhostAnime
In response to GhostAnime
Doesn't flick finish all of the frames for that icon state? Thats what it does in my game, but yeah your right it does return quite quickly, I guess it just depends on how you create your icon state
In response to KirbyAllStar
Yeah, it does flick through the icon_state but what I am saying is that because you have density=1 right after flick(), it's usually like you never had density=0 in there before.

So lets say that the door animation had 10 frames with a delay of 1:
density=0
flick("Open",src)
sleep(10*1) // If this wasn't here, USUALLY it would go to the next line almost immidiately instead of waiting for the animation to be done
density=1
flick("Close",src")


- GhostAnime
In response to GhostAnime
oh ok that makes since sorry about that
In response to KirbyAllStar
It's no problem, you learn more everyday :)

- GhostAnime