Files
Bubberstation/code/modules/modular_computers/hardware/printer.dm
Watermelon914 375a20e49b Refactors most spans into span procs (#59645)
Converts most spans into span procs. Mostly used regex for this and sorted out any compile time errors afterwards so there could be some bugs.
Was initially going to do defines, but ninja said to make it into a proc, and if there's any overhead, they can easily be changed to defines.

Makes it easier to control the formatting and prevents typos when creating spans as it'll runtime if you misspell instead of silently failing.
Reduces the code you need to write when writing spans, as you don't need to close the span as that's automatically handled by the proc.

(Note from Lemon: This should be converted to defines once we update the minimum version to 514. Didn't do it now because byond pain and such)
2021-06-14 13:03:53 -07:00

63 lines
1.8 KiB
Plaintext

/obj/item/computer_hardware/printer
name = "printer"
desc = "Computer-integrated printer with paper recycling module."
power_usage = 100
icon_state = "printer"
w_class = WEIGHT_CLASS_NORMAL
device_type = MC_PRINT
expansion_hw = TRUE
var/stored_paper = 20
var/max_paper = 30
/obj/item/computer_hardware/printer/diagnostics(mob/living/user)
..()
to_chat(user, span_notice("Paper level: [stored_paper]/[max_paper]."))
/obj/item/computer_hardware/printer/examine(mob/user)
. = ..()
. += span_notice("Paper level: [stored_paper]/[max_paper].")
/obj/item/computer_hardware/printer/proc/print_text(text_to_print, paper_title = "")
if(!stored_paper)
return FALSE
if(!check_functionality())
return FALSE
var/obj/item/paper/P = new/obj/item/paper(holder.drop_location())
// Damaged printer causes the resulting paper to be somewhat harder to read.
if(damage > damage_malfunction)
P.info = stars(text_to_print, 100-malfunction_probability)
else
P.info = text_to_print
if(paper_title)
P.name = paper_title
P.update_appearance()
stored_paper--
P = null
return TRUE
/obj/item/computer_hardware/printer/try_insert(obj/item/I, mob/living/user = null)
if(istype(I, /obj/item/paper))
if(stored_paper >= max_paper)
to_chat(user, span_warning("You try to add \the [I] into [src], but its paper bin is full!"))
return FALSE
if(user && !user.temporarilyRemoveItemFromInventory(I))
return FALSE
to_chat(user, span_notice("You insert \the [I] into [src]'s paper recycler."))
qdel(I)
stored_paper++
return TRUE
return FALSE
/obj/item/computer_hardware/printer/mini
name = "miniprinter"
desc = "A small printer with paper recycling module."
power_usage = 50
icon_state = "printer_mini"
w_class = WEIGHT_CLASS_TINY
stored_paper = 5
max_paper = 15