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.
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.
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.
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.
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.