ID:145920
 
Code:
        Door()
set category = "Build"
if(src.Nobuild())
var/O = new/obj/Door(usr.loc) //creates a new door in the usr's loc
O:owner = "[usr.key]"
switch(input("What direction is your door?","Dir") in list("North","South","East","West"))
if("North")
dir="north"
if("South")
dir="south"
if("East")
dir="east"
if("West")
dir="west"
var/password = input("What is the password(leave it blank for none)")as text
if(!password)
O:pass = "None"
return
O:pass = password
Tree()
set category = "Build"
if(src.Nobuild())
var/O = new/obj/Tree(usr.loc) //creates a tree using icon states
O:owner = "[usr.key]"
switch(input("What part of the tree do you wish to build?","part") in list("top-right","top-left","bottom-right","bottom-left"))
if("top-right")
icon_state="tr overlay"
density = 0
layer = MOB_LAYER+1
if("top-left")
icon_state="tl overlay"
density = 0
layer = MOB_LAYER+1
if("bottom-right")
icon_state="br"
density = 1
if("bottom-left")
icon_state="bl"
density = 1


Problem description:
well the first one I was trying to get it where the player can build a door and then choose a direction to face it. (using the directional icons inside the dmi file...
The second one is a tree I was hoping I can do using icon states for selection upon building... I know i have it incorrect because simply nither one will work.
If somebody can rewrite this for me so I can see how it works for future use please do.

First off, I would like to say that you should not use colons whenever possible, and very rarely is in not possible. In fact, it's almost impossible for you to have a reason to use a colon.

Secondly, what's all this if North, if South? You should be using a variable instead if a switch statement, much smaller code, not to mention quicker.

For the last part on this first part of the code, you have indented your if statements that ask for the password too far.

    Door()
set category = "Build"
if(!src.Nobuild()) return
var/obj/Door/O = new(src.loc)
O.owner = "[src.key]"
O.dir=input("What direction is your door?","Dir") in list(NORTH,SOUTH,EAST,WEST))
var/password = input("What is the password(leave it blank for none)")as text
if(!password) O.pass = "None"
else O.pass = password


Now, about the tree, you might as well build the whole thing. Why ask for icon_states? Anyway, the best way to do this is to build the two dense, base parts of the tree, and set a pixel overlay for them.

    Tree()
set category = "Build"
if(!src.Nobuild()) return
var/obj/Tree/B1 = new(usr.loc)
var/obj/Tree/B2 = new(locate(src.x+1,src.y,src.z))
var/obj/Tree/T1 = new(B1.overlays)
var/obj/Tree/T2 = new(B2.overlays)
O.owner = "[src.key]"
B1.icon_state="bl"
B2.icon_state="br"
T1.icon_state="tl overlay"
T2.icon_state="tr overlay"
T1.pixel_y=32
T2.pixel_y=32


That is no most efficient as it could be, but it will work. As for your tree, you'll need to place density=1 under it.

obj/Tree
icon=''
icon_state=""
density=1


It doesn't matter that you have two tree parts that aren't supposed to be dense because overlays are passable. There's no density within an overlay.
In response to CaptFalcon33035
thanks for the correction, I'm rather new at doing this and thought I would try to be as descriptive as possible with my issue. I thank you as well for being most descriptive with your answer as I can understand it. Most people say read the guide n00b or something like that... if there was a user rating system here you would get a 10 from me.
In response to Kator
Thanks, but for those who tell you to read the 'n00b guide', they are 'n00bs' themselves. There is no such guide. There is a DM Guide, which I am sure they are trying to refer to, there is a DM reference, which is a list of most of the variables and procs and other things that you will at some point want or need to learn, there is a Developer FAQ, and other content in the form of tutorials, demos, and libraries that users have uploaded to share with the community.