From e875af3d56ef0a00e9d6a4588accbc412a7938bd Mon Sep 17 00:00:00 2001 From: MINIMAN10000 Date: Fri, 13 Apr 2018 16:48:14 -0700 Subject: [PATCH 1/3] Cable Coils can partial transfer, stripped depereciated code, changed cable coil message --- code/game/objects/items/stacks/stack.dm | 5 ++++- code/modules/power/cable.dm | 19 ++----------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index 582432c06b7..6a631f53e38 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -13,6 +13,7 @@ var/list/recipes = list() // /datum/stack_recipe var/singular_name var/amount = 1 + var/to_transfer = 0 var/max_amount //also see stack recipes initialisation, param "max_res_amount" must be equal to this max_amount var/merge_type = null // This path and its children should merge with this stack, defaults to src.type @@ -231,6 +232,9 @@ /obj/item/stack/proc/get_max_amount() return max_amount +/obj/item/stack/proc/get_amount_transferred() + return to_transfer + /obj/item/stack/proc/split(mob/user, amt) var/obj/item/stack/F = new type(loc, amt) F.copy_evidences(src) @@ -257,7 +261,6 @@ if(S.amount >= max_amount) return 1 - var/to_transfer if(user.is_in_inactive_hand(src)) var/desired = input("How much would you like to transfer from this stack?", "How much?", 1) as null|num if(!desired) diff --git a/code/modules/power/cable.dm b/code/modules/power/cable.dm index 0914cdc8d32..9e377d0ca71 100644 --- a/code/modules/power/cable.dm +++ b/code/modules/power/cable.dm @@ -589,30 +589,15 @@ var/global/list/datum/stack_recipe/cable_coil_recipes = list( if(istype(W, /obj/item/stack/cable_coil)) var/obj/item/stack/cable_coil/C = W if(C.amount >= MAXCOIL) - to_chat(user, "The coil is too long, you cannot add any more cable to it.") + to_chat(user, "The coil is as long as it will get.") return - if( (C.amount + src.amount <= MAXCOIL) ) to_chat(user, "You join the cable coils together.") - C.give(src.amount) // give it cable - src.use(src.amount) // make sure this one cleans up right return - else - var/amt = MAXCOIL - C.amount - to_chat(user, "You transfer [amt] length\s of cable from one coil to the other.") - C.give(amt) - src.use(amt) + to_chat(user, "You transfer [get_amount_transferred()] length\s of cable from one coil to the other.") return -//add cables to the stack -/obj/item/stack/cable_coil/proc/give(var/extra) - if(amount + extra > MAXCOIL) - amount = MAXCOIL - else - amount += extra - update_icon() - /////////////////////////////////////////////// // Cable laying procedures ////////////////////////////////////////////// From 5d52f60d9d165c5cb68497b27eb6a5a97cb36a96 Mon Sep 17 00:00:00 2001 From: MINIMAN10000 Date: Fri, 13 Apr 2018 18:27:20 -0700 Subject: [PATCH 2/3] Comment about where merging is handled, moved to_transfer variable to immediately above where it is used --- code/game/objects/items/stacks/stack.dm | 2 +- code/modules/power/cable.dm | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index 6a631f53e38..2d22191f6fc 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -13,7 +13,6 @@ var/list/recipes = list() // /datum/stack_recipe var/singular_name var/amount = 1 - var/to_transfer = 0 var/max_amount //also see stack recipes initialisation, param "max_res_amount" must be equal to this max_amount var/merge_type = null // This path and its children should merge with this stack, defaults to src.type @@ -232,6 +231,7 @@ /obj/item/stack/proc/get_max_amount() return max_amount +var/to_transfer = 0 /obj/item/stack/proc/get_amount_transferred() return to_transfer diff --git a/code/modules/power/cable.dm b/code/modules/power/cable.dm index 9e377d0ca71..356d293ddf8 100644 --- a/code/modules/power/cable.dm +++ b/code/modules/power/cable.dm @@ -588,6 +588,7 @@ var/global/list/datum/stack_recipe/cable_coil_recipes = list( ..() if(istype(W, /obj/item/stack/cable_coil)) var/obj/item/stack/cable_coil/C = W + // Cable merging is handled by parent proc if(C.amount >= MAXCOIL) to_chat(user, "The coil is as long as it will get.") return From d4a98ea09f92d77c0761f812ced642de3ed69855 Mon Sep 17 00:00:00 2001 From: MINIMAN10000 Date: Fri, 13 Apr 2018 19:50:26 -0700 Subject: [PATCH 3/3] Moved var/to_transfer back to /obj/item/stack turns out it's fine there --- code/game/objects/items/stacks/stack.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index 2d22191f6fc..6a631f53e38 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -13,6 +13,7 @@ var/list/recipes = list() // /datum/stack_recipe var/singular_name var/amount = 1 + var/to_transfer = 0 var/max_amount //also see stack recipes initialisation, param "max_res_amount" must be equal to this max_amount var/merge_type = null // This path and its children should merge with this stack, defaults to src.type @@ -231,7 +232,6 @@ /obj/item/stack/proc/get_max_amount() return max_amount -var/to_transfer = 0 /obj/item/stack/proc/get_amount_transferred() return to_transfer