mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 03:02:54 +00:00
streamlined copy machine code
This commit is contained in:
@@ -3,23 +3,17 @@
|
|||||||
/obj/machinery/copier
|
/obj/machinery/copier
|
||||||
name = "Copy Machine"
|
name = "Copy Machine"
|
||||||
icon = 'bureaucracy.dmi'
|
icon = 'bureaucracy.dmi'
|
||||||
icon_state = "copier"
|
icon_state = "copier_o"
|
||||||
density = 1
|
density = 1
|
||||||
anchored = 1
|
anchored = 1
|
||||||
var/num_copies = 1 // number of copies selected, will be maintained between jobs
|
var/num_copies = 1 // number of copies selected, will be maintained between jobs
|
||||||
var/copying = 0 // are we copying
|
var/copying = 0 // are we copying
|
||||||
var/job_num_copies = 0 // number of copies remaining
|
var/job_num_copies = 0 // number of copies remaining
|
||||||
var/top_open = 1 // the top is open
|
|
||||||
var/obj/item/weapon/template // the paper OR photo being scanned
|
var/obj/item/weapon/template // the paper OR photo being scanned
|
||||||
var/copy_wait = 0 // wait for current page to finish
|
|
||||||
var/max_copies = 10 // MAP EDITOR: can set the number of max copies, possibly to 5 or something for public, more for QM, robutist, etc.
|
var/max_copies = 10 // MAP EDITOR: can set the number of max copies, possibly to 5 or something for public, more for QM, robutist, etc.
|
||||||
|
|
||||||
/obj/machinery/copier/New()
|
|
||||||
..()
|
|
||||||
update()
|
|
||||||
|
|
||||||
/obj/machinery/copier/attackby(obj/item/weapon/O as obj, mob/user as mob)
|
/obj/machinery/copier/attackby(obj/item/weapon/O as obj, mob/user as mob)
|
||||||
if(!top_open)
|
if(template)
|
||||||
return
|
return
|
||||||
|
|
||||||
if (istype(O, /obj/item/weapon/paper) || istype(O, /obj/item/weapon/photo))
|
if (istype(O, /obj/item/weapon/paper) || istype(O, /obj/item/weapon/photo))
|
||||||
@@ -27,7 +21,6 @@
|
|||||||
template = O
|
template = O
|
||||||
usr.drop_item()
|
usr.drop_item()
|
||||||
O.loc = src
|
O.loc = src
|
||||||
top_open = 0
|
|
||||||
update()
|
update()
|
||||||
updateDialog()
|
updateDialog()
|
||||||
|
|
||||||
@@ -37,63 +30,55 @@
|
|||||||
/obj/machinery/copier/attack_ai(user as mob)
|
/obj/machinery/copier/attack_ai(user as mob)
|
||||||
return src.attack_hand(user)
|
return src.attack_hand(user)
|
||||||
|
|
||||||
/obj/machinery/copier/attack_hand(user as mob)
|
/obj/machinery/copier/attack_hand(mob/user as mob)
|
||||||
// da UI
|
// da UI
|
||||||
var/dat
|
var/dat
|
||||||
if(..())
|
if(..())
|
||||||
return
|
return
|
||||||
|
user.machine = src
|
||||||
|
|
||||||
if(src.stat)
|
if(src.stat)
|
||||||
user << "[name] does not seem to be responding to your button mashing."
|
user << "[name] does not seem to be responding to your button mashing."
|
||||||
return
|
return
|
||||||
|
|
||||||
/*
|
|
||||||
if(top_open)
|
|
||||||
user << "[name] beeps, \"Please place a paper on top and close the lid.\""
|
|
||||||
return
|
|
||||||
*/
|
|
||||||
|
|
||||||
dat = "<HEAD><TITLE>Copy Machine</TITLE></HEAD><TT><b>Xeno Corp. Copying Machine</b><hr>"
|
dat = "<HEAD><TITLE>Copy Machine</TITLE></HEAD><TT><b>Xeno Corp. Copying Machine</b><hr>"
|
||||||
|
|
||||||
if(copying)
|
if(copying)
|
||||||
dat += "[job_num_copies] copies remaining.<br><br>"
|
dat += "[job_num_copies] copies remaining.<br><br>"
|
||||||
dat += "<A href='?src=\ref[src];cancel=1'>Cancel</a>"
|
dat += "<A href='?src=\ref[src];cancel=1'>Cancel</A>"
|
||||||
else
|
else
|
||||||
if(!top_open)
|
|
||||||
dat += "<A href='?src=\ref[src];open=1'>Open Top</a><br><br>"
|
|
||||||
|
|
||||||
dat += "Number of Copies: "
|
|
||||||
|
|
||||||
dat += "<A href='?src=\ref[src];num=-10'>-</a>"
|
|
||||||
dat += "<A href='?src=\ref[src];num=-1'>-</a>"
|
|
||||||
dat += " [num_copies] "
|
|
||||||
dat += "<A href='?src=\ref[src];num=1'>+</a>"
|
|
||||||
dat += "<A href='?src=\ref[src];num=10'>+</a><br><br>"
|
|
||||||
|
|
||||||
if(template)
|
if(template)
|
||||||
dat += "<A href='?src=\ref[src];copy=1'>Copy</a>"
|
dat += "<A href='?src=\ref[src];open=1'>Open Lid</A>"
|
||||||
else
|
else
|
||||||
dat += "<b>No paper to be copied.<br>"
|
dat += "<b>No paper to be copied.<br>"
|
||||||
dat += "Please place a paper or photograph on top and close the lid.</b>"
|
dat += "Please place a paper or photograph on top and close the lid.</b>"
|
||||||
|
|
||||||
dat += "<hr></TT>"
|
|
||||||
|
dat += "<br><br>Number of Copies: "
|
||||||
|
dat += "<A href='?src=\ref[src];num=-10'>-</A>"
|
||||||
|
dat += "<A href='?src=\ref[src];num=-1'>-</A>"
|
||||||
|
dat += " [num_copies] "
|
||||||
|
dat += "<A href='?src=\ref[src];num=1'>+</A>"
|
||||||
|
dat += "<A href='?src=\ref[src];num=10'>+</A><br>"
|
||||||
|
|
||||||
|
if(template)
|
||||||
|
dat += "<A href='?src=\ref[src];copy=1'>Copy</a>"
|
||||||
|
|
||||||
|
dat += "</TT>"
|
||||||
|
|
||||||
user << browse(dat, "window=copy_machine")
|
user << browse(dat, "window=copy_machine")
|
||||||
onclose(user, "copy_machine")
|
onclose(user, "copy_machine")
|
||||||
|
|
||||||
/obj/machinery/copier/proc/update()
|
/obj/machinery/copier/proc/update()
|
||||||
if(top_open)
|
if(template)
|
||||||
icon_state = "copier_o"
|
|
||||||
else if(copying)
|
|
||||||
icon_state = "copier_s"
|
|
||||||
else
|
|
||||||
icon_state = "copier"
|
icon_state = "copier"
|
||||||
|
else
|
||||||
|
icon_state = "copier_o"
|
||||||
|
|
||||||
/obj/machinery/copier/Topic(href, href_list)
|
/obj/machinery/copier/Topic(href, href_list)
|
||||||
if(..())
|
if(..())
|
||||||
return
|
return
|
||||||
usr.machine = src
|
usr.machine = src
|
||||||
src.add_fingerprint(usr)
|
|
||||||
|
|
||||||
if(href_list["num"])
|
if(href_list["num"])
|
||||||
num_copies += text2num(href_list["num"])
|
num_copies += text2num(href_list["num"])
|
||||||
@@ -103,35 +88,36 @@
|
|||||||
num_copies = max_copies
|
num_copies = max_copies
|
||||||
updateDialog()
|
updateDialog()
|
||||||
if(href_list["open"])
|
if(href_list["open"])
|
||||||
|
if(copying)
|
||||||
|
return
|
||||||
template.loc = src.loc
|
template.loc = src.loc
|
||||||
template = null
|
template = null
|
||||||
top_open = 1
|
|
||||||
updateDialog()
|
updateDialog()
|
||||||
update()
|
update()
|
||||||
if(href_list["copy"])
|
if(href_list["copy"])
|
||||||
copying = 1
|
if(copying)
|
||||||
|
return
|
||||||
job_num_copies = num_copies
|
job_num_copies = num_copies
|
||||||
update()
|
spawn(0)
|
||||||
updateDialog()
|
do_copy(usr)
|
||||||
if(href_list["cancel"])
|
|
||||||
copying = 0
|
|
||||||
job_num_copies = 0
|
|
||||||
update()
|
|
||||||
updateDialog()
|
|
||||||
|
|
||||||
/obj/machinery/copier/process()
|
if(href_list["cancel"])
|
||||||
if(src.stat)
|
job_num_copies = 0
|
||||||
usr << "[name] does not seem to be responding to your button mashing."
|
|
||||||
|
/obj/machinery/copier/proc/do_copy(mob/user)
|
||||||
|
if(!copying && job_num_copies > 0)
|
||||||
|
copying = 1
|
||||||
|
updateDialog()
|
||||||
|
while(job_num_copies > 0)
|
||||||
|
if(stat)
|
||||||
|
copying = 0
|
||||||
return
|
return
|
||||||
|
|
||||||
if(copying && !copy_wait)
|
// fx
|
||||||
copy_wait = 1
|
flick("copier_s", src)
|
||||||
// make noise
|
|
||||||
playsound(src, 'polaroid1.ogg', 50, 1)
|
playsound(src, 'polaroid1.ogg', 50, 1)
|
||||||
spawn(5)
|
|
||||||
if(!copying)
|
|
||||||
return // user cancelled
|
|
||||||
|
|
||||||
|
// dup the file
|
||||||
if(istype(template, /obj/item/weapon/paper))
|
if(istype(template, /obj/item/weapon/paper))
|
||||||
// make duplicate paper
|
// make duplicate paper
|
||||||
var/obj/item/weapon/paper/P = new(src.loc)
|
var/obj/item/weapon/paper/P = new(src.loc)
|
||||||
@@ -139,6 +125,9 @@
|
|||||||
P.info = template:info
|
P.info = template:info
|
||||||
P.stamped = template:stamped
|
P.stamped = template:stamped
|
||||||
P.icon_state = template.icon_state
|
P.icon_state = template.icon_state
|
||||||
|
P.overlays = null
|
||||||
|
for(var/overlay in template.overlays)
|
||||||
|
P.overlays += overlay
|
||||||
else if(istype(template, /obj/item/weapon/photo))
|
else if(istype(template, /obj/item/weapon/photo))
|
||||||
// make duplicate photo
|
// make duplicate photo
|
||||||
var/obj/item/weapon/photo/P = new(src.loc)
|
var/obj/item/weapon/photo/P = new(src.loc)
|
||||||
@@ -146,11 +135,10 @@
|
|||||||
P.desc = template.desc
|
P.desc = template.desc
|
||||||
P.icon = template.icon
|
P.icon = template.icon
|
||||||
|
|
||||||
// copy counting stuff
|
sleep(30)
|
||||||
job_num_copies -= 1
|
job_num_copies -= 1
|
||||||
if(job_num_copies == 0)
|
|
||||||
usr << "[name] beeps happily."
|
|
||||||
copying = 0
|
|
||||||
update()
|
|
||||||
updateDialog()
|
updateDialog()
|
||||||
copy_wait = 0
|
for(var/mob/O in hearers(src))
|
||||||
|
O.show_message("[name] beeps happily.", 2)
|
||||||
|
copying = 0
|
||||||
|
updateDialog()
|
||||||
Reference in New Issue
Block a user