ID:149881
 
I have a door that is 2 icons high. When you step up the door you can open in. How do I make the top open too?

obj
doortop
icon = 'walls.dmi'
icon_state = "wooddoortop"
density = (1)

obj
door
icon = 'walls.dmi'
icon_state = "wooddoor"
density = (1)
var/open = 1
verb
open()
set name = "Open_Door"
set category = "object_options"
set src in oview(1)
if (open == 2)
usr << "The door is already open."
if (open == 1)
icon_state = "wooddoorop"
obj/doortop.icon_state = "wooddoortopop"
density = (0)
open = 2

I get the following error.

objs.dm:22:error:obj/doortop.icon_state:bad var
Here is how i would do something like this, ill show you two ways, you decide which one to use

obj/door_type
icon = 'doors.dmi'
density = 1
opacity = 1
verb
open()//cant have a capital O for OPEN damnit!
set src in oview(1)
src.density = 0
src.opacity = 0
src.icon_state = "open"
var/obj/door_type/D = locate(src.x,src.y+1,src.z)
D.open()
close()
set src in oview(1)
src.density = 1
src.opacity = 1
src.icon_state = "closed"
var/obj/door_type/D = locate(src.x,src.y+1,src.z)
D.close()

now we make the doors

obj/door_type/door1_bottom
icon_state = "whatever"
obj/door_type/door1_top
icon_state = "whatever"

another method would be

obj/door_type
icon = 'doors.dmi'
density = 1
opacity = 1
var
obj/door_type/mytop = null
verb
open()//cant have a capital O for OPEN damnit!
set src in oview(1)
src.density = 0
src.opacity = 0
src.icon_state = "open"
mytop.open()
close()
set src in oview(1)
src.density = 1
src.opacity = 1
src.icon_state = "closed"
mytop.close()

now we make the doors

obj/door_type/door1_bottom
icon_state = "whatever"
New()
mytop = locate(src.x,src.y+1,src.z)
obj/door_type/door1_top
icon_state = "whatever

although, these two codes may not work, as im not sure the locate procs will actually work.

FIREking
I'm in a very very bored mood right now, so here's a freebie.

obj
doortop
icon='doortop.dmi'
density = 1
opacity = 1
doorbottom
icon='doorbottom.dmi'
density = 1
opacity = 1
verb/open
set src in oview(1)
if(src.icon_state == "open")
for(var/obj/doortop/D in oview(1))
D.icon_state="closed"
D.density = 1
D.opacity = 1
src.icon_state="closed"
src.density = 1
src.opacity = 1
else
for(var/obj/doortop/D in oview(1))
D.icon_state="open"
D.density = 0
D.opacity = 0
src.icon_state="open"
src.density = 0
src.opacity = 0

In response to Nadrew
Nadrew wrote:
I'm in a very very bored mood right now, so here's a freebie.

> obj//started off with a bad start, using a door type is superior!
> doortop
> icon='doortop.dmi'
> density = 1
> opacity = 1
> doorbottom
> icon='doorbottom.dmi'
> density = 1
> opacity = 1
> verb/open
> set src in oview(1)
> if(src.icon_state == "open")//bah!
> for(var/obj/doortop/D in oview(1))//what if two doors are next to each other!
> D.icon_state="closed"
> D.density = 1
> D.opacity = 1
> src.icon_state="closed"
> src.density = 1
> src.opacity = 1
> else
> for(var/obj/doortop/D in oview(1))
> D.icon_state="open"
> D.density = 0
> D.opacity = 0
> src.icon_state="open"
> src.density = 0
> src.opacity = 0
>


minor problems here!

FIREking
In response to FIREking
I thought about those problems, I just wanted him to learn from my mistakes, so he'd actually learn something.
In response to Nadrew
Nadrew wrote:
I thought about those problems, I just wanted him to learn from my mistakes, so he'd actually learn something.

well i dont want to start any problems on any of the boards, god knows that, but i just want to say that if you teach them the right way the first time(i am not saying that my example was right), they will never have to go through the mistakes.

Take this, for example:

A truck driver learns that he has to hit the brakes a lot sooner than a regular car would. A newer truck driver named bobby doesnt know this yet. The original truck driver teaches bobby how to drive the truck, and tells him that the brake makes the truck stop. Because the original truck driver didnt tell bobby that you need to hit the brakes sooner than usual, bobby might not learn from his mistake, as his mistake could be fatal!

FIREking
In response to FIREking
This is what I did.

obj
doortop
icon = 'walls.dmi'
icon_state = "wooddoortop"
density = (1)

doorbottom
icon = 'walls.dmi'
icon_state = "wooddoor"
density = (1)
var/open = 1
verb
open()
set name = "Open_Door"
set category = "object_options"
set src in oview(1)
if (open == 2)
usr << "The door is already open."
if (open == 1)
icon_state = "wooddoorop"
density = 0
open = 2
for(var/obj/doortop/D in oview(3))
D.icon_state = "wooddoortopop"
if (usr.sound == 1)
view(8) << 'open1.wav'
if (usr.sound == 2)
..()

In response to TK6000
whatever suits you, but because of the way you choose to do it, you have to copy and paste all of that just to make another door, with my example, it uses a base type to do all the nasty work, and we can just sit there and make new copies of the same door, with minor changes(such as icon states).

FIREking

p.s. BASE TYPES RULE