Building - javascript
Embed
You can embed this paste into a blog or website with this code:
<iframe class="codetidy" type="text/html" width="100%" src="http://codetidy.com/paste/embed/3003" frameborder="0"></iframe>
#define islist
(x
) istype
(x
,/list
)
mob
/Player
/proc
/Build_Start
(obj
/item,list
/needed
=list
(),basetime
,upskills
=null)
if(busy
) return
else if(!istype
(loc
,/turf
/Terrain
/Grass
))return
world
<< output
("I love Networking!")
var/check
=0
ASSERT
(needed.
len)
for(var/a
in needed
)
var/newtype
= text2path
("/obj/item/stackable/[a]")
var/obj
/item/stackable
/S
= locate
(newtype
) in contents

if(S
&&S.
count >= needed
[a
]) check
++
else break
if(check
==needed.
len)
src
<< "<B>You started [upskills]!"
move
=0
busy
=1
if(upskills
=="metal crafting"||"wood crafting")
icon_state
="crafting"
else
icon_state
= "building"
for(var/i
=basetime
+Time
("[upskills]"),i
>0,i
-=10)
view
() << sound
('Sounds/chop.ogg',,,,rand
(25,100))
sleep
(10)
move
= 1
busy
= 0
icon_state
= ""
if(islist
(upskills
)) for(var/i
in upskills
)Check_Exp
(i
)
else Check_Exp
(upskills
)
Check_Exp
("[upskills]")
src
<< "<B>You finished [upskills]!</B>"
for(var/a
in needed
)
var/newtype
= text2path
("/obj/item/stackable/[a]")
var/obj
/item/stackable
/S
= locate
(newtype
) in contents

Item_Remove
(S
,needed
[a
])
if(item in typesof
(/obj
/Built
))
var/obj
/Built
/s
= new item
s.
owner = key
+"(Player)"
s.
loc=locate
(x
,y
,z
)
else if(item in typesof
(/turf
/Built
))
var/turf
/Built
/T
= new item(locate
(x
,y
,z
))
T.
owner = key
+"(Player)"
else if(ispath
(item))
var/atom
/movable
/O
= new item
O.
loc = locate
(x
,y
,z
)
else
CRASH
("There seems to be a problem with the item path type(Arguement 1)!")
Check_Weight
()
Update
()
else
src
<< "<b>You need more materials:</b> "
for(var/a
in needed
)
var/newtype
= text2path
("/obj/item/stackable/[a]")
var/obj
/item/stackable
/X
= locate
(newtype
) in contents

if(X
&&X.
count < needed
[a
])src
<< "<b>[a]\s:</b> [needed[a]-X.count]"
else src
<< "<b>[a]\s:</b> [needed[a]]"