mirror of
https://github.com/CHOMPstation/CHOMPstation.git
synced 2026-08-24 20:46:29 +01:00
POLARIS: Fixes #5282 (VS) - Allow use of pens to label pill bottles, like glass bottles
This commit is contained in:
@@ -173,6 +173,43 @@
|
||||
max_storage_space = ITEMSIZE_COST_TINY * 14
|
||||
max_w_class = ITEMSIZE_TINY
|
||||
|
||||
var/label_text = ""
|
||||
var/base_name = " "
|
||||
var/base_desc = " "
|
||||
|
||||
/obj/item/weapon/storage/pill_bottle/New()
|
||||
..()
|
||||
base_name = name
|
||||
base_desc = desc
|
||||
|
||||
/obj/item/weapon/storage/pill_bottle/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
if(istype(W, /obj/item/weapon/pen) || istype(W, /obj/item/device/flashlight/pen))
|
||||
var/tmp_label = sanitizeSafe(input(user, "Enter a label for [name]", "Label", label_text), MAX_NAME_LEN)
|
||||
if(length(tmp_label) > 50)
|
||||
to_chat(user, "<span class='notice'>The label can be at most 50 characters long.</span>")
|
||||
else if(length(tmp_label) > 10)
|
||||
to_chat(user, "<span class='notice'>You set the label.</span>")
|
||||
label_text = tmp_label
|
||||
update_name_label()
|
||||
else
|
||||
to_chat(user, "<span class='notice'>You set the label to \"[tmp_label]\".</span>")
|
||||
label_text = tmp_label
|
||||
update_name_label()
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/item/weapon/storage/pill_bottle/proc/update_name_label()
|
||||
if(!label_text)
|
||||
name = base_name
|
||||
desc = base_desc
|
||||
return
|
||||
else if(length(label_text) > 10)
|
||||
var/short_label_text = copytext(label_text, 1, 11)
|
||||
name = "[base_name] ([short_label_text]...)"
|
||||
else
|
||||
name = "[base_name] ([label_text])"
|
||||
desc = "[base_desc] It is labeled \"[label_text]\"."
|
||||
|
||||
/obj/item/weapon/storage/pill_bottle/antitox
|
||||
name = "bottle of Dylovene pills"
|
||||
desc = "Contains pills used to counter toxins."
|
||||
|
||||
Reference in New Issue
Block a user