Implemented crude crafting

Debug messages are still inside, pushing only cozx pete asked me to

Conflicts:
	code/_globalvars/lists/objects.dm
	code/game/objects/structures/tables_racks.dm
This commit is contained in:
Razharas
2014-01-21 21:56:53 +04:00
committed by ZomgPonies
parent c21586250d
commit 56e56b31a6
2 changed files with 96 additions and 1 deletions
@@ -10,6 +10,19 @@
/*
* Tables
*/
/datum/table_recipe
var/name = ""
var/reqs[]
var/result_path
/datum/table_recipe/flame_thrower
name = "Flamethrower"
result_path = /obj/item/weapon/flamethrower
reqs = list("/obj/item/weapon/weldingtool" = 1,
"/obj/item/device/assembly/igniter" = 1,
"/obj/item/stack/rods" = 2)
/obj/structure/table
name = "table"
desc = "A square piece of metal standing on four metal legs. It can not move."
@@ -22,6 +35,7 @@
var/parts = /obj/item/weapon/table_parts
var/flipped = 0
var/health = 100
var/list/table_contents = list()
/obj/structure/table/proc/update_adjacent()
for(var/direction in list(1,2,4,8,5,6,9,10))
@@ -41,12 +55,78 @@
update_adjacent()
..()
/obj/structure/table/proc/destroy()
new parts(loc)
density = 0
del(src)
/obj/structure/table/proc/check_contents(datum/table_recipe/TR)
var/datum/table_recipe/R = TR
world.log << "Here comes the [TR]"
var/i = R.reqs.len
world.log << "Its req.length is [i]"
for(var/A in R.reqs)
world.log << "It needs [R.reqs[A]] [A], and there is only [table_contents[A]]"
if(table_contents[A] < R.reqs[A])
break
else
i--
if(i<=0)
return 1
else
return 0
/obj/structure/table/proc/del_reqs(datum/table_recipe/TR)
var/datum/table_recipe/R = TR
for(var/A in R.reqs)
var/obj/item/I = locate(text2path(A)) in loc
if(istype(I, /obj/item/stack))
var/obj/item/stack/S = I
S.amount -= R.reqs[A]
else
for(var/i=R.reqs[A],i>=0,i--)
I = locate(text2path(A)) in loc
del(I)
/obj/structure/table/interact(mob/user)
for(var/A in table_recipes)
world.log << "[A]"
table_contents = list()
for(var/obj/item/I in loc)
if(istype(I, /obj/item/stack))
var/obj/item/stack/S = I
table_contents["[I.type]"] += S.amount
else
table_contents["[I.type]"] += 1
if(!table_contents.len)
return
var/dat = "<h3>Construction menu</h3>"
dat += "<div class='statusDisplay'>"
for(var/datum/table_recipe/R in table_recipes)
if(check_contents(R))
dat += "<A href='?src=\ref[src];make=\ref[R]'>[R.name]</A><BR>"
dat += "</div>"
var/datum/browser/popup = new(user, "table", "Table", 300, 300)
popup.set_content(dat)
popup.open()
return
/obj/structure/table/Topic(href, href_list)
if(usr.stat || !Adjacent(usr) || usr.lying)
return
if(href_list["make"])
var/datum/table_recipe/TR = locate(href_list["make"])
if(check_contents(TR))
del_reqs(TR)
var/obj/item/I = new TR.result_path
I.loc = loc
usr << "<span class='notice'>You crafted [I.name].</span>"
attack_hand(usr)
/obj/structure/table/update_icon()
if(flipped)
var/type = 0
@@ -283,6 +363,8 @@
visible_message("<span class='danger'>[user] smashes [src] apart!</span>")
user.say(pick(";RAAAAAAAARGH!", ";HNNNNNNNNNGGGGGGH!", ";GWAAAAAAAARRRHHH!", "NNNNNNNNGGGGGGGGHH!", ";AAAAAAARRRGH!" ))
destroy()
else
interact(user)
/obj/structure/table/attack_tk() // no telehulk sorry
return