Files
Polaris/code/modules/assembly/timer.dm
Kelenius db30c15e4c Updates to science
Protolathe and CI build procs moved to them from RD console.
Protolathe and CI now have a build queue. Designs take varying time to
build.
P and CI material storage is now a list instead of a set of vars.
origin_tech is now a list.
All sheets now contain exactly 2000 units of matter.
In design datum, chemicals and materials are two separate lists.
Designs are now sorted. The method is kinda hacky but flexible. They
have a var, sort_string. Designs are sorted alphabetically using it.
Circuits how show whether they build a machine or a computer in CI menu.
Adds item construction, for now protolathe is used.
2015-04-04 13:38:03 +03:00

109 lines
2.4 KiB
Plaintext

/obj/item/device/assembly/timer
name = "timer"
desc = "Used to time things. Works well with contraptions which has to count down. Tick tock."
icon_state = "timer"
matter = list("metal" = 500, "glass" = 50, "waste" = 10)
origin_tech = list(TECH_MAGNET = 1)
wires = WIRE_PULSE
secured = 0
var/timing = 0
var/time = 10
proc
timer_end()
activate()
if(!..()) return 0//Cooldown check
timing = !timing
update_icon()
return 0
toggle_secure()
secured = !secured
if(secured)
processing_objects.Add(src)
else
timing = 0
processing_objects.Remove(src)
update_icon()
return secured
timer_end()
if(!secured) return 0
pulse(0)
if(!holder)
visible_message("\icon[src] *beep* *beep*", "*beep* *beep*")
cooldown = 2
spawn(10)
process_cooldown()
return
process()
if(timing && (time > 0))
time--
if(timing && time <= 0)
timing = 0
timer_end()
time = 10
return
update_icon()
overlays.Cut()
attached_overlays = list()
if(timing)
overlays += "timer_timing"
attached_overlays += "timer_timing"
if(holder)
holder.update_icon()
return
interact(mob/user as mob)//TODO: Have this use the wires
if(!secured)
user.show_message("\red The [name] is unsecured!")
return 0
var/second = time % 60
var/minute = (time - second) / 60
var/dat = text("<TT><B>Timing Unit</B>\n[] []:[]\n<A href='?src=\ref[];tp=-30'>-</A> <A href='?src=\ref[];tp=-1'>-</A> <A href='?src=\ref[];tp=1'>+</A> <A href='?src=\ref[];tp=30'>+</A>\n</TT>", (timing ? text("<A href='?src=\ref[];time=0'>Timing</A>", src) : text("<A href='?src=\ref[];time=1'>Not Timing</A>", src)), minute, second, src, src, src, src)
dat += "<BR><BR><A href='?src=\ref[src];refresh=1'>Refresh</A>"
dat += "<BR><BR><A href='?src=\ref[src];close=1'>Close</A>"
user << browse(dat, "window=timer")
onclose(user, "timer")
return
Topic(href, href_list)
if(..()) return 1
if(!usr.canmove || usr.stat || usr.restrained() || !in_range(loc, usr))
usr << browse(null, "window=timer")
onclose(usr, "timer")
return
if(href_list["time"])
timing = text2num(href_list["time"])
update_icon()
if(href_list["tp"])
var/tp = text2num(href_list["tp"])
time += tp
time = min(max(round(time), 0), 600)
if(href_list["close"])
usr << browse(null, "window=timer")
return
if(usr)
attack_self(usr)
return