ID:167504
 
obj/Redline_Door_Openable
name = "Door"
icon = 'Door.dmi'
icon_state = "Closed"
opacity = 1
density = 1
Pickup = 0
layer = 99
Click(mob)
if(get_dist(mob,usr) <= 1)
if (icon_state == "Closed")
usr << "The door opens."
density = 0
opacity = 0
icon_state = "Open"
else
if(get_dist(mob,usr) != 0)
usr << "The door closes."
density = 1
opacity = 1
icon_state = "Closed"
else
usr << "The door is blocked!"
else
return


I'm looking for something that detects something of density in the doorway (My attempt: if(get_dist(mob,usr) != 0) so the door can't close.

NOTE: Do NOT comment the code.


EDIT: That then comes onto the next part of work: Maybe I could use that Follow Me library, but I need a idea on how to Push/Pull.
var/mob/a = locate() in src
if(a)
balbalabla
In response to Mysame
Brilliant, but can it be extended, like If(a.density == 0) blahblah?


I tried it, it didn't work. (Extending)
In response to RedlineM203
obj/Redline_Door_Openable
name = "Door"
icon = 'Door.dmi'
icon_state = "Closed"
opacity = 1
density = 1
Pickup = 0
layer = 99
Click(mob)
if(get_dist(mob,usr) <= 1)
if (icon_state == "Closed")
usr << "The door opens."
density = 0
opacity = 0
icon_state = "Open"
else
var/mob/a=locate() in src
if(a && a.density) {src<<"Someone is in!";return}
usr << "The door closes."
density = 1
opacity = 1
icon_state = "Closed"
else
usr << "The door is blocked!"


Don't mind the indendation
In response to Mysame
Fighter.dm:586: Inconsistent indentation. (var/mob/a=locate() in src)
Fighter.dm:587: Inconsistent indentation. ( if(a && a.density) {src<<"Someone is in!";return})
Fighter.dm:588: Inconsistent indentation. (usr << "The door closes.")

Fighter.dmb - 5 errors, 0 warnings (double-click on an error to jump to it)



Yes... I do mind now.
In response to RedlineM203
RedlineM203 wrote:
Yes... I do mind now.

That obviously will happen when you directly copy and paste code from the forums to your game. You have to type it back in yourself, and learn from it, otherwise you won't be getting anywhere.

~~> Unknown Person
In response to Unknown Person
I already did that, taking 5 minutes. Still errors.
In response to RedlineM203
RedlineM203 wrote:
I already did that, taking 5 minutes. Still errors.

Then show the code you wrote, and help will be given to you.

O-matic
In response to O-matic
Author: Mysame [Posts]
Date: 3/5/06 6:30 am
Topic: Re: Blocking doors
obj/Redline_Door_Openable
name = "Door"
icon = 'Door.dmi'
icon_state = "Closed"
opacity = 1
density = 1
Pickup = 0
layer = 99
Click(mob)
if(get_dist(mob,usr) <= 1)
if (icon_state == "Closed")
usr << "The door opens."
density = 0
opacity = 0
icon_state = "Open"
else
var/mob/a=locate() in src
if(a && a.density) {src<<"Someone is in!";return}
usr << "The door closes."
density = 1
opacity = 1
icon_state = "Closed"
else
usr << "The door is blocked!"



Don't mind the indendation



You should of looked...
In response to RedlineM203
Euhm, no. O-Matic means that you probably mis-indented the mis-indendation of the forums. So, show us your current door code. o.o;;
In response to Mysame
obj/Redline_Door_Openable
name = "Door"
icon = 'Door.dmi'
icon_state = "Closed"
opacity = 1
density = 1
Pickup = 0
layer = 99
Click(mob)
if(get_dist(mob,usr) <= 1)
if (icon_state == "Closed")
usr << "The door opens."
density = 0
opacity = 0
icon_state = "Open"
else
var/mob/a=locate() in src
if(a && a.density) {src<<"The door is blocked!";return}
usr << "The door closes."
density = 1
opacity = 1
icon_state = "Closed"
else
usr << "The door is blocked!"


The only difference is what it says when the density of A is 1.
In response to RedlineM203
Oh for the love of Christ, you can't fix an indendation? Just delete the spaces the forums use and replace them by tabs to they're correct.
In response to Mysame
^I already did that, taking 5 minutes. Still errors.


I'll do it again once more!


obj/Redline_Door_Openable
name = "Door"
icon = 'Door.dmi'
icon_state = "Closed"
opacity = 1
density = 1
Pickup = 0
layer = 99
Click(mob)
if(get_dist(mob,usr) <= 1)
if (icon_state == "Closed")
usr << "The door opens."
density = 0
opacity = 0
icon_state = "Open"
else
var/mob/a=locate() in src
if(a && a.density) {src<<"The door is blocked!";return}
usr << "The door closes."
density = 1
opacity = 1
icon_state = "Closed"
else
usr << "The door is blocked!"


loading Fighter.dme
Fighter.dm:588:error::invalid expression (usr << "The door closes.")
Fighter.dm:592:error:else :'else' clause without preceding 'if' statement (Else to go with the If(a && a.density))

Fighter.dmb - 2 errors, 0 warnings (double-click on an error to jump to it)
In response to RedlineM203
You indented everything after the if. NORMALLY that is correct, though I added everything that happens in the if() BEHIND it. So just un-indent all those lines by 1.
In response to Mysame
Ok. It works... ish.

You open the door.
(Table, Wall and me are in the doorway)
You close the door.
In response to RedlineM203
The table won't do a thing, nor will the wall. Can't you see it was var/mob/a = locate() in src? Of course, you can always try, if(locate(var/mob/a) in src) return 0
In response to Mysame
            else
var/mob/a=locate() in src
if(locate(var/mob/a) in src)
usr << "The door is blocked!"
return 0
else
usr << "The door closes."
density = 1
opacity = 1
icon_state = "Closed"


loading Fighter.dme
Fighter.dm:610:error:var/mob/a:undefined var
Fighter.dm:609:a :warning: variable defined but not used

Fighter.dmb - 1 error, 1 warning (double-click on an error to jump to it)


var/mob/a is defined, but not. Urgh...
In response to RedlineM203
meh, stick to var/mob/a = locate() in src, if that doesn't work, slap your DM.
In response to Mysame
DM doesn't seem to like you today.
In response to KirbyRules
Wouldn't it be simpler to have the dooors opened when entered, and then closed exited?