ID:173971
 
Hello y'all. I have these Castle Portcullis's, and when someone bumps into them I want them to open, so he can walk through. I did this code :

turf
Castle
BottomLeft
icon = 'Castle.dmi'
icon_state = "BL"
density = 1
Bump()
flick("BLopen",src)
src.density = 0
Exit()
src.density = 1
BottomRight
icon = 'Castle.dmi'
icon_state = "BR"
density = 1
Bump()
flick("BRopen",src)
src.density = 0
Exit()
src.density = 1
BottomMiddle
icon = 'Castle.dmi'
icon_state = "BM"
density = 1
Bump()
flick("BMopen",src)
src.density = 0
Exit()
src.density = 1


But for some reason it says Bump is undefined! Any help would be greatly appreciated!

~Ease~
Bump is a /atom/movable proc that is called by Move when a moving object is blocked. The moving object is the src, not the blocking object. If you want to do something like you have there, it is common to make a Bumped proc.
atom/proc/Bumped(atom/movable/A)

atom/movable/Bump(atom/A)
A.Bumped(src)
In response to Loduwijk
Couldn't you also do:

mob
Bump(turf/T)
if(istype(T,/turf/Castle))
T.flick("icon_state",T)
T.density=0

Just checking, I'm pretty sure that would work too
In response to Airjoe
Yes, you could work around it that way. I was just showing him a way to keep his code relatively the same as he has it by simply modifying something else. This way he can continue doing it his way.
In response to Loduwijk
Thanks you guys!

~Ease~
In response to Ease
Erm, yeh... I am still getting some problems. When the person bumps them, they flick the icon state, which for some reason is black in the background, not "see-through". But they cannot walk through it!

My code is now :
atom/proc/Bumped(atom/movable/A)

atom/movable/Bump(atom/A)
A.Bumped(src)

turf
Castle
BottomLeft
icon = 'Castle.dmi'
icon_state = "BL"
density = 1
Bumped()
flick("BLopen",src)
src.density = 0
Exit()
src.density = 1
BottomRight
icon = 'Castle.dmi'
icon_state = "BR"
density = 1
Bumped()
flick("BRopen",src)
src.density = 0
Exit()
src.density = 1
BottomMiddle
icon = 'Castle.dmi'
icon_state = "BM"
density = 1
Bumped()
flick("BMopen",src)
src.density = 0
Exit()
src.density = 1


Thank you.

~Ease~
In response to Ease
Have you changed the turf's Enter() function at all? That might be your problem if you have.
In response to Loduwijk
Nope, I am sure that I have not altered the Enter procs in anyway! I have done nothing to the turfs other than that included in my posted code snippet.

~Ease~
In response to Ease
I just noticed something else. You are using Exit() instead of Exited(). I suggest you change that to Exitted(), because using Exit() the way you have it you will never be able to walk off of that turf.
In response to Loduwijk
Thank you! Now I can walk on and through the turfs, but the icon flick is still odd colours? Oh well!

Any more help would be greatfully recieved!

~Ease~
In response to Ease
If you use turf without any see trew spaces ins the original icon it replaces anything under it and when you change it to see trew, it will just be black
In response to FranquiBoy
But the first icon_state did have see-through bits in, and I had placed it on top of anotehr turf. Surely when flicked it would still see the other turf below it still.

~Ease~
In response to Ease
Well, you can't stack turfs.. you just can't. thats why I recomend making doors etc as objects, because if there is any "holes" in the icon flick.. the "holes" will appear black. but if you use objects, when you flick the "holes" will just be filled by the turf under the object. If this makes no sense I'm sorry I must of misunderstood, it is late..

Trog
In response to Troglodyte
No, it makes perfect sense! Thank you!

~Ease~
In response to Troglodyte
Not a huge deal, but I thought I would point something out. I keep seeing people use the word "objects" to refer to objects of type /obj, such as in your last post you said that you suggest making it an object instead of a turf. Technically, everything derived from atom is an object. Turfs, areas, mobs and objs are all objects, the one that is type /obj just coincidentally has its class name similar to the term "object".

Like I said, 'tis not a huge deal and most people do it. But if you start talking like that and get a newbie to think that when someone says object they allways mean an object of type /obj then it could turn into a big deal, since in that case they could get all confused and have a horrible habbit. I, for one, had that problem when I first started learning this byond stuff. I started thinking of only obj as objects, then when I would get help from some of the users that had been here and knew what they were doing they might refer to a turf or a mob as an object and I would get confused, so I know it does happen. Thankfully, I purchased a book about object-oriented programming and read up on it, so now I know quite a bit more and have been set straight. But there are most likely others that do not have that fortunate opportunity.

So, it might not seem like a huge deal, but I suggest you start calling things for what they are even if only to keep those you are helping from gaining a bad habbit.

-Loduwijk
In response to Loduwijk
You've got a good point. I, for one, wil try to refer to objects of /obj type to /obj from now on.