Files
CHOMPStation2/code/modules/paperwork/handlabeler.dm
2020-02-12 19:38:43 -05:00

68 lines
2.4 KiB
Plaintext

/obj/item/weapon/hand_labeler
name = "hand labeler"
desc = "Label everything like you've always wanted to! Stuck to the side is a label reading \'Labeler\'. Seems you're too late for that one."
icon = 'icons/obj/bureaucracy.dmi'
icon_state = "labeler0"
var/label = null
var/labels_left = 30
var/mode = 0 //off or on.
/obj/item/weapon/hand_labeler/attack()
return
/obj/item/weapon/hand_labeler/afterattack(atom/A, mob/user as mob, proximity)
if(!proximity)
return
if(!mode) //if it's off, give up.
return
if(A == loc) // if placing the labeller into something (e.g. backpack)
return // don't set a label
if(!labels_left)
to_chat(user, "<span class='notice'>No labels left.</span>")
return
if(!label || !length(label))
to_chat(user, "<span class='notice'>No text set.</span>")
return
if(length(A.name) + length(label) > 64)
to_chat(user, "<span class='notice'>Label too big.</span>")
return
if(ishuman(A))
to_chat(user, "<span class='notice'>The label refuses to stick to [A.name].</span>")
return
if(issilicon(A))
to_chat(user, "<span class='notice'>The label refuses to stick to [A.name].</span>")
return
if(isobserver(A))
to_chat(user, "<span class='notice'>[src] passes through [A.name].</span>")
return
if(istype(A, /obj/item/weapon/reagent_containers/glass))
to_chat(user, "<span class='notice'>The label can't stick to the [A.name]. (Try using a pen)</span>")
return
if(istype(A, /obj/machinery/portable_atmospherics/hydroponics))
var/obj/machinery/portable_atmospherics/hydroponics/tray = A
if(!tray.mechanical)
to_chat(user, "<span class='notice'>How are you going to label that?</span>")
return
tray.labelled = label
spawn(1)
tray.update_icon()
user.visible_message("<span class='notice'>[user] labels [A] as [label].</span>", \
"<span class='notice'>You label [A] as [label].</span>")
A.name = "[A.name] ([label])"
/obj/item/weapon/hand_labeler/attack_self(mob/user as mob)
mode = !mode
icon_state = "labeler[mode]"
if(mode)
to_chat(user, "<span class='notice'>You turn on \the [src].</span>")
//Now let them chose the text.
var/str = sanitizeSafe(input(user,"Label text?","Set label",""), MAX_NAME_LEN)
if(!str || !length(str))
to_chat(user, "<span class='notice'>Invalid text.</span>")
return
label = str
to_chat(user, "<span class='notice'>You set the text to '[str]'.</span>")
else
to_chat(user, "<span class='notice'>You turn off \the [src].</span>")