diff --git a/code/__DEFINES/is_helpers.dm b/code/__DEFINES/is_helpers.dm index 6a51b057434..c41fffdbed8 100644 --- a/code/__DEFINES/is_helpers.dm +++ b/code/__DEFINES/is_helpers.dm @@ -158,6 +158,8 @@ GLOBAL_LIST_INIT(turfs_without_ground, typecacheof(list( #define isitem(A) (istype(A, /obj/item)) +#define isstack(A) (istype(A, /obj/item/stack)) + #define isgrenade(A) (istype(A, /obj/item/grenade)) #define islandmine(A) (istype(A, /obj/effect/mine)) diff --git a/code/game/objects/structures/table_frames.dm b/code/game/objects/structures/table_frames.dm index 7992b9f7f92..515e987b887 100644 --- a/code/game/objects/structures/table_frames.dm +++ b/code/game/objects/structures/table_frames.dm @@ -21,36 +21,48 @@ var/framestack = /obj/item/stack/rods var/framestackamount = 2 -/obj/structure/table_frame/attackby(obj/item/I, mob/user, params) - if(I.tool_behaviour == TOOL_WRENCH) - to_chat(user, "You start disassembling [src]...") - I.play_tool_sound(src) - if(I.use_tool(src, user, 30)) - playsound(src.loc, 'sound/items/deconstruct.ogg', 50, TRUE) - deconstruct(TRUE) - return - var/obj/item/stack/material = I - if (istype(material)) - if(material?.tableVariant) +/obj/structure/table_frame/wrench_act(mob/living/user, obj/item/I) + to_chat(user, "You start disassembling [src]...") + I.play_tool_sound(src) + if(!I.use_tool(src, user, 3 SECONDS)) + return TRUE + playsound(loc, 'sound/items/deconstruct.ogg', 50, TRUE) + deconstruct(TRUE) + return TRUE + + +/obj/structure/table_frame/attackby(obj/item/I, mob/user, params) + if(isstack(I)) + var/obj/item/stack/material = I + if(material.tableVariant) if(material.get_amount() < 1) to_chat(user, "You need one [material.name] sheet to do this!") return + if(locate(/obj/structure/table) in loc) + to_chat(user, "There's already a table built here!") + return to_chat(user, "You start adding [material] to [src]...") - if(do_after(user, 20, target = src) && material.use(1)) - make_new_table(material.tableVariant) + if(!do_after(user, 2 SECONDS, target = src) || !material.use(1) || (locate(/obj/structure/table) in loc)) + return + make_new_table(material.tableVariant) else if(istype(material, /obj/item/stack/sheet)) if(material.get_amount() < 1) to_chat(user, "You need one sheet to do this!") return + if(locate(/obj/structure/table) in loc) + to_chat(user, "There's already a table built here!") + return to_chat(user, "You start adding [material] to [src]...") - if(do_after(user, 20, target = src) && material.use(1)) - var/list/material_list = list() - if(material.material_type) - material_list[material.material_type] = MINERAL_MATERIAL_AMOUNT - make_new_table(/obj/structure/table/greyscale, material_list) - else - return ..() + if(!do_after(user, 2 SECONDS, target = src) || !material.use(1) || (locate(/obj/structure/table) in loc)) + return + var/list/material_list = list() + if(material.material_type) + material_list[material.material_type] = MINERAL_MATERIAL_AMOUNT + make_new_table(/obj/structure/table/greyscale, material_list) + return + return ..() + /obj/structure/table_frame/proc/make_new_table(table_type, custom_materials) //makes sure the new table made retains what we had as a frame var/obj/structure/table/T = new table_type(loc)