From 1fe801e1558aa84a4d6c0eed57d6f13b94820f49 Mon Sep 17 00:00:00 2001 From: Ashe Higgs Date: Mon, 19 Feb 2018 15:45:58 -0500 Subject: [PATCH 1/2] Adds a debug circuitry printer, along with some assorted circuit fixes and tweaks (#35578) * Some more circuitry foolin' * Fixes blood draw not working --- .../integrated_electronics/core/analyzer.dm | 2 +- .../integrated_electronics/core/printer.dm | 23 +++++++++++++------ .../integrated_electronics/subtypes/input.dm | 8 +++---- .../integrated_electronics/subtypes/output.dm | 22 +++++++++--------- .../subtypes/reagents.dm | 6 +++-- 5 files changed, 36 insertions(+), 25 deletions(-) diff --git a/code/modules/integrated_electronics/core/analyzer.dm b/code/modules/integrated_electronics/core/analyzer.dm index 0166f9bce7..bd7804bf45 100644 --- a/code/modules/integrated_electronics/core/analyzer.dm +++ b/code/modules/integrated_electronics/core/analyzer.dm @@ -8,7 +8,7 @@ /obj/item/device/integrated_electronics/analyzer/afterattack(var/atom/A, var/mob/living/user) if(istype(A, /obj/item/device/electronic_assembly)) - var/saved = SScircuit.save_electronic_assembly(A) + var/saved = "[A.name] analyzed! On circuit printers with cloning enabled, you may use the code below to clone the circuit:

[SScircuit.save_electronic_assembly(A)]" if(saved) to_chat(user, "You scan [A].") user << browse(saved, "window=circuit_scan;size=500x600;border=1;can_resize=1;can_close=1;can_minimize=1") diff --git a/code/modules/integrated_electronics/core/printer.dm b/code/modules/integrated_electronics/core/printer.dm index 7ee035a2ec..66c65dbbf9 100644 --- a/code/modules/integrated_electronics/core/printer.dm +++ b/code/modules/integrated_electronics/core/printer.dm @@ -6,6 +6,7 @@ w_class = WEIGHT_CLASS_BULKY var/upgraded = FALSE // When hit with an upgrade disk, will turn true, allowing it to print the higher tier circuits. var/can_clone = FALSE // Same for above, but will allow the printer to duplicate a specific assembly. + var/debug = FALSE // If it's upgraded and can clone, even without config settings. var/current_category = null var/recycling = FALSE // If an assembly is being emptied into this printer var/list/program // Currently loaded save, in form of list @@ -17,6 +18,11 @@ upgraded = TRUE can_clone = TRUE +/obj/item/device/integrated_circuit_printer/debug //translation: "integrated_circuit_printer/local_server" + name = "debug circuit printer" + debug = TRUE + w_class = WEIGHT_CLASS_TINY + /obj/item/device/integrated_circuit_printer/Initialize() . = ..() AddComponent(/datum/component/material_container, list(MAT_METAL), MINERAL_MATERIAL_AMOUNT * 25, TRUE, list(/obj/item/stack, /obj/item/integrated_circuit, /obj/item/device/electronic_assembly)) @@ -92,17 +98,20 @@ var/datum/component/material_container/materials = GetComponent(/datum/component/material_container) var/HTML = "

Integrated Circuit Printer


" - HTML += "Metal: [materials.total_amount]/[materials.max_amount].

" + if(debug) + HTML += "

DEBUG PRINTER -- Infinite materials. Cloning available.

" + else + HTML += "Metal: [materials.total_amount]/[materials.max_amount].

" - if(CONFIG_GET(flag/ic_printing)) + if(CONFIG_GET(flag/ic_printing) && !debug) HTML += "Assembly cloning: [can_clone ? "Available": "Unavailable"].
" - HTML += "Circuits available: [upgraded ? "Advanced":"Regular"]." + HTML += "Circuits available: [upgraded || debug ? "Advanced":"Regular"]." if(!upgraded) HTML += "
Crossed out circuits mean that the printer is not sufficiently upgraded to create that circuit." HTML += "
" - if(can_clone && CONFIG_GET(flag/ic_printing)) + if((can_clone && CONFIG_GET(flag/ic_printing)) || debug) HTML += "Here you can load script for your assembly.
" HTML += " {Load Program} " if(!program) @@ -160,7 +169,7 @@ var/datum/component/material_container/materials = GetComponent(/datum/component/material_container) - if(!materials.use_amount_type(cost, MAT_METAL)) + if(!debug && !materials.use_amount_type(cost, MAT_METAL)) to_chat(usr, "You need [cost] metal to build that!") return TRUE @@ -176,7 +185,7 @@ playsound(src, 'sound/items/jaws_pry.ogg', 50, TRUE) if(href_list["print"]) - if(!CONFIG_GET(flag/ic_printing)) + if(!CONFIG_GET(flag/ic_printing) && !debug) to_chat(usr, "CentCom has disabled printing of custom circuitry due to recent allegations of copyright infringement.") return if(!can_clone) // Copying and printing ICs is cloning @@ -217,7 +226,7 @@ to_chat(usr, "This program uses unknown component designs. Printer upgrade is required to proceed.") else var/datum/component/material_container/materials = GetComponent(/datum/component/material_container) - if(materials.use_amount_type(program["metal_cost"], MAT_METAL)) + if(debug || materials.use_amount_type(program["metal_cost"], MAT_METAL)) var/obj/item/assembly = SScircuit.load_electronic_assembly(get_turf(src), program) to_chat(usr, "[assembly] has been printed from the provided template!") playsound(src, 'sound/items/poster_being_created.ogg', 50, TRUE) diff --git a/code/modules/integrated_electronics/subtypes/input.dm b/code/modules/integrated_electronics/subtypes/input.dm index c22e38d56a..b927132983 100644 --- a/code/modules/integrated_electronics/subtypes/input.dm +++ b/code/modules/integrated_electronics/subtypes/input.dm @@ -18,7 +18,7 @@ spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH /obj/item/integrated_circuit/input/button/ask_for_input(mob/user) //Bit misleading name for this specific use. - to_chat(user, "You press the button labeled '[src]'.") + to_chat(user, "You press the button labeled '[displayed_name]'.") activate_pin(1) /obj/item/integrated_circuit/input/toggle_button @@ -36,7 +36,7 @@ set_pin_data(IC_OUTPUT, 1, !get_pin_data(IC_OUTPUT, 1)) push_data() activate_pin(1) - to_chat(user, "You toggle the button labeled '[src]' [get_pin_data(IC_OUTPUT, 1) ? "on" : "off"].") + to_chat(user, "You toggle the button labeled '[displayed_name]' [get_pin_data(IC_OUTPUT, 1) ? "on" : "off"].") /obj/item/integrated_circuit/input/numberpad name = "number pad" @@ -51,7 +51,7 @@ power_draw_per_use = 4 /obj/item/integrated_circuit/input/numberpad/ask_for_input(mob/user) - var/new_input = input(user, "Enter a number, please.","Number pad") as null|num + var/new_input = input(user, "Enter a number, please.",displayed_name) as null|num if(isnum(new_input) && user.IsAdvancedToolUser()) set_pin_data(IC_OUTPUT, 1, new_input) push_data() @@ -70,7 +70,7 @@ power_draw_per_use = 4 /obj/item/integrated_circuit/input/textpad/ask_for_input(mob/user) - var/new_input = stripped_input(user, "Enter some words, please.","Text pad") + var/new_input = stripped_input(user, "Enter some words, please.",displayed_name) if(istext(new_input) && user.IsAdvancedToolUser()) set_pin_data(IC_OUTPUT, 1, new_input) push_data() diff --git a/code/modules/integrated_electronics/subtypes/output.dm b/code/modules/integrated_electronics/subtypes/output.dm index 6a90ff5f2a..127755a01a 100644 --- a/code/modules/integrated_electronics/subtypes/output.dm +++ b/code/modules/integrated_electronics/subtypes/output.dm @@ -83,17 +83,6 @@ assembly.set_light(0) power_draw_idle = light_toggled ? light_brightness * 2 : 0 -/obj/item/integrated_circuit/output/light/advanced/update_lighting() - var/new_color = get_pin_data(IC_INPUT, 1) - var/brightness = get_pin_data(IC_INPUT, 2) - - if(new_color && isnum(brightness)) - brightness = CLAMP(brightness, 0, 6) - light_rgb = new_color - light_brightness = brightness - - ..() - /obj/item/integrated_circuit/output/light/power_fail() // Turns off the flashlight if there's no power left. light_toggled = FALSE update_lighting() @@ -113,6 +102,17 @@ /obj/item/integrated_circuit/output/light/advanced/on_data_written() update_lighting() +/obj/item/integrated_circuit/output/light/advanced/update_lighting() + var/new_color = get_pin_data(IC_INPUT, 1) + var/brightness = get_pin_data(IC_INPUT, 2) + + if(new_color && isnum(brightness)) + brightness = CLAMP(brightness, 0, 6) + light_rgb = new_color + light_brightness = brightness + + ..() + /obj/item/integrated_circuit/output/sound name = "speaker circuit" desc = "A miniature speaker is attached to this component." diff --git a/code/modules/integrated_electronics/subtypes/reagents.dm b/code/modules/integrated_electronics/subtypes/reagents.dm index f70d55e570..9e267b120c 100644 --- a/code/modules/integrated_electronics/subtypes/reagents.dm +++ b/code/modules/integrated_electronics/subtypes/reagents.dm @@ -193,7 +193,7 @@ activate_pin(3) return - var/tramount = CLAMP(transfer_amount, 0, AM.reagents.total_volume) + var/tramount = abs(transfer_amount) if(isliving(AM)) var/mob/living/L = AM @@ -202,13 +202,15 @@ busy = TRUE if(do_atom(src, L, extra_checks=CALLBACK(L, /mob/living/proc/can_inject,null,0))) if(L.transfer_blood_to(src, tramount)) - L.visible_message("[acting_object] takes a blood sample from [L].") + L.visible_message("[acting_object] takes a blood sample from [L]!", \ + "[acting_object] takes a blood sample from you!") else busy = FALSE activate_pin(3) return busy = FALSE else + tramount = min(tramount, AM.reagents.total_volume) if(!AM.reagents.total_volume) activate_pin(3) return