mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-16 09:29:38 +01:00
Extends and reworks how various extended information text (desc_info, desc_build, desc_upgrades) are handled to make object interactions and mechanics A.) much more clearly documented in-game and B.) much easier to support from the back-end. Almost certainly a candidate for test merge. Assembly/Disassembly instructions are noticeably sporadic, largely due to our current lack of a unified framework. That's a future thing I'd like to attack so that it can be handled programmatically, but for now I only targeted the biggest culprits as I came across them. --------- Signed-off-by: Batrachophreno <Batrochophreno@gmail.com>
102 lines
3.8 KiB
Plaintext
102 lines
3.8 KiB
Plaintext
/obj/item/paper_scanner
|
|
name = "paper scanner"
|
|
desc = "A simple device that can be used to scan paper or paper bundles in order to digitize them."
|
|
icon = 'icons/obj/devices/paperscanner.dmi'
|
|
icon_state = "paperscanner"
|
|
item_state = "paperscanner"
|
|
contained_sprite = TRUE
|
|
var/obj/item/computer_hardware/hard_drive/portable/drive
|
|
|
|
/obj/item/paper_scanner/mechanics_hints(mob/user, distance, is_adjacent)
|
|
. += ..()
|
|
. += "Click paper or a paper bundle with it to digitize it and store it in the inserted drive."
|
|
. += "ALT-click it while it's in one of your hands to eject the portable drive."
|
|
|
|
/obj/item/paper_scanner/Initialize(mapload, ...)
|
|
. = ..()
|
|
drive = new /obj/item/computer_hardware/hard_drive/portable(src)
|
|
update_icon()
|
|
|
|
/obj/item/paper_scanner/update_icon()
|
|
ClearOverlays()
|
|
if(drive)
|
|
AddOverlays("paperscanner-drive")
|
|
|
|
/obj/item/paper_scanner/AltClick(mob/living/user)
|
|
if(!drive)
|
|
to_chat(user, SPAN_WARNING("\The [src] doesn't have a drive installed."))
|
|
return
|
|
if(!istype(user))
|
|
to_chat(user, SPAN_WARNING("You're too simple to work \the [src]."))
|
|
return
|
|
if(user.l_hand == src || user.r_hand == src || issilicon(user))
|
|
to_chat(user, SPAN_NOTICE("You eject \the [drive]."))
|
|
user.put_in_hands(drive)
|
|
drive = null
|
|
update_icon()
|
|
else
|
|
to_chat(user, SPAN_WARNING("You must be holding \the [src] in one of your hands before you can eject a drive."))
|
|
|
|
/obj/item/paper_scanner/attackby(obj/item/attacking_item, mob/user)
|
|
if(istype(attacking_item, /obj/item/computer_hardware/hard_drive/portable))
|
|
if(drive)
|
|
to_chat(user, SPAN_WARNING("\The [src] already has a drive installed!"))
|
|
return TRUE
|
|
to_chat(user, SPAN_NOTICE("You insert \the [attacking_item] into \the [src]."))
|
|
user.drop_from_inventory(attacking_item, src)
|
|
drive = attacking_item
|
|
update_icon()
|
|
return TRUE
|
|
else
|
|
return ..()
|
|
|
|
/obj/item/paper_scanner/afterattack(atom/target, mob/user, proximity_flag, click_parameters)
|
|
if(proximity_flag && (istype(target, /obj/item/paper) || istype(target, /obj/item/paper_bundle)))
|
|
do_scan(target, user)
|
|
|
|
/obj/item/paper_scanner/proc/do_scan(var/obj/item/target, var/mob/user)
|
|
if(!drive)
|
|
to_chat(user, SPAN_WARNING("\The [src] doesn't have a drive installed."))
|
|
return
|
|
|
|
var/list/pages_to_scan = list()
|
|
var/obj/item/paper/P = target
|
|
var/obj/item/paper_bundle/PB = target
|
|
|
|
if(istype(P))
|
|
if(!P.info)
|
|
to_chat(user, SPAN_WARNING("\The [P] doesn't have any information on it."))
|
|
return
|
|
pages_to_scan += P
|
|
else if(istype(PB))
|
|
var/has_info = FALSE
|
|
for(var/obj/item/paper/page in PB.pages)
|
|
if(page.info)
|
|
pages_to_scan += page
|
|
has_info = TRUE
|
|
if(!has_info)
|
|
to_chat(user, SPAN_WARNING("\The [PB] doesn't have any information in it."))
|
|
return
|
|
|
|
if(!length(pages_to_scan))
|
|
return
|
|
|
|
user.visible_message("<b>[user]</b> starts making a scan of \the [target]...", SPAN_NOTICE("You start making a scan of \the [target]..."), range = 3)
|
|
if(do_after(user, 30 * length(pages_to_scan), target))
|
|
if(!drive)
|
|
to_chat(user, SPAN_WARNING("\The [src] doesn't have a drive installed."))
|
|
return
|
|
user.visible_message("<b>[user]</b> makes a scan of \the [target].", SPAN_NOTICE("You make a scan of \the [target]."), range = 3)
|
|
var/datum/computer_file/data/F = new /datum/computer_file/data(drive)
|
|
F.filename = target.name != initial(target.name) ? "[target.name] ([worldtime2text()] - [time2text(world.time, "Month DD")])" : "Digital Paper ([worldtime2text()] - [time2text(world.time, "Month DD")])"
|
|
F.filetype = "TXT"
|
|
var/data_to_save = ""
|
|
for(var/thing in pages_to_scan)
|
|
var/obj/item/paper/page = thing
|
|
var/p_info = html2pencode(page.info)
|
|
data_to_save += strip_html_properly(p_info)
|
|
data_to_save += "\[br\]"
|
|
F.stored_data = data_to_save
|
|
if(!drive.store_file(F))
|
|
to_chat(user, SPAN_WARNING("\The [drive] does not have enough space to store the latest scanned file."))
|