ID:145480
 
Code:
obj
Door1
desc = "Click the door to open it."
var/password = null
var/OpenPass
icon = 'Door 1.dmi'
icon_state = "Closed"
density = 1
opacity = 1
Bump(obj/Door1)
..()
if(password == null)
icon_state = "Open"
density = 0
opacity = 0
sleep(30)
icon_state = "Closed"
density = 1
opacity = 1
else
OpenPass = input("Type in the password.") as text
if(OpenPass == password)
icon_state = "Open"
density = 0
opacity = 0
sleep(30)
icon_state = "Closed"
density = 1
opacity = 1
else if(OpenPass != password)
usr << "INCORRECT PASSWORD!!"


Problem description:

I'm trying to make doors that when you bump into them they open, but when I run the game and bump into the door, nothing happens.
Uhm, the door never bumps into anything, but it does get bumpED by the player. The object that's moving is the one that's doing the bumping, so you can change it like this:
atom/proc/Bumped()
atom/movable/Bump(atom/A)
..()
A.Bumped(src)

obj
Door1
...
Bumped(atom/movable/A)
...
In response to Crashed
Crashed wrote:
> atom/proc/Bumped()
> atom/movable/Bump(atom/A)
> ..()
> A.Bumped(src)


I don't really understand what you're trying to do there.
In response to KirbyRules
He's passing the bumper to the thing being bumped and vica-versa.
In response to Mysame
I mean why is atom/proc/Bumped() empty? Also I tryed it and it didn't work.
In response to KirbyRules
You need to insert whatever you want it to do. Change atom/ to mob/ or obj/ to fit all of your Bump() likeness.
In response to Mysame
All I wanna know is why doesn't Bump() work? Am I putting the wrong arguements in?
In response to KirbyRules
The way you coded it, the door needed to bump into something named obj/door1...
In response to Mysame
So what do I change the obj/door1 to? Do I need to change it to mob/M? If so I tryed that and it didn't work.
In response to KirbyRules
You use the code posted above, and use Bumped. Bumped is used when you bump into something else.
In response to KirbyRules
KirbyRules wrote:
I tryed it and it didn't work.
http://members.byond.com/ProgrammingArticles?post=4289

Read it properly instead of skim reading it for your answer and you'll understand.
In response to DeathAwaitsU
The door still doesn't open.
In response to KirbyRules
After having read the article, what do you now have?
In response to DeathAwaitsU
mob/Bump(atom/A)
..()
if(istype(A,/obj/Door1) || istype(A,/obj/Door2))
if(A:password == null)
A.icon_state = "Open"
A.density = 0
A.opacity = 0
sleep(30)
A.icon_state = "Closed"
A.density = 1
A.opacity = 1
else
var/OpenPass = input("Type in the password.") as text
if(OpenPass == A:password)
A.icon_state = "Open"
A.density = 0
A.opacity = 0
sleep(30)
A.icon_state = "Closed"
A.density = 1
A.opacity = 1
else if(OpenPass != A:password)
usr << "INCORRECT PASSWORD!!"
In response to KirbyRules
If you got that from reading the article then you didn't follow my directions. I said READ the article, not SKIM READ it. Try again.
In response to DeathAwaitsU
I did read the article. I read the whole Bump() thing.
In response to KirbyRules
Just try using the Enter proc on the door instead of making bumps on everything.
In response to Dever
Enter() is for turfs isn't it?
In response to KirbyRules
Read the first sentence I wrote, that tells you why it won't work. And that piece of code does work, you're just doing something wrong (perhaps you didn't change Bump to Bumped, or a preceeding Bump() doesn't have the default call (..())).
Page: 1 2