-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a paper scanner device that can scan paper and paper bundles and convert them into data files.
- Loading branch information
Showing
7 changed files
with
292 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/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." | ||
desc_info = "Alt-click it while it's in one of your hands to eject the portable drive. Click paper or a paper bundle with it to digitize it and store it in the inserted drive." | ||
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/Initialize(mapload, ...) | ||
. = ..() | ||
drive = new /obj/item/computer_hardware/hard_drive/portable(src) | ||
update_icon() | ||
|
||
/obj/item/paper_scanner/update_icon() | ||
cut_overlays() | ||
if(drive) | ||
add_overlay("paperscanner-drive") | ||
|
||
/obj/item/paper_scanner/AltClick(mob/living/carbon/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) | ||
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/W, mob/user) | ||
if(istype(W, /obj/item/computer_hardware/hard_drive/portable)) | ||
if(drive) | ||
to_chat(user, SPAN_WARNING("\The [src] already has a drive installed!")) | ||
return | ||
to_chat(user, SPAN_NOTICE("You insert \the [W] into \the [src].")) | ||
user.drop_from_inventory(W, src) | ||
drive = W | ||
update_icon() | ||
else | ||
..() | ||
|
||
/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), TRUE, 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 | ||
data_to_save += page.info | ||
data_to_save += "\[br\]" | ||
F.stored_data = data_to_save | ||
if(!drive.store_file(F)) | ||
to_chat(usr, SPAN_WARNING("\The [drive] does not have enough space to store the latest scanned file.")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
author: Geeves | ||
|
||
delete-after: True | ||
|
||
changes: | ||
- rscadd: "Added a paper scanner device that can scan paper and paper bundles and convert them into data files." |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.