* Adds "RUN ONCE" button to the AAC.

* 5s delay on runonce.

* Fixes #12920

* Fixes from testing.

* Probe's suggestions.
This commit is contained in:
Rob Nelson
2017-02-14 13:47:54 -08:00
committed by sood
parent 3887dd0725
commit 8b0decb884
2 changed files with 49 additions and 25 deletions

View File

@@ -17,6 +17,8 @@
var/list/linked_assemblies = list() //Can have up to 5 assemblies connected. AAC scripts can pulse them
var/const/max_linked_assembly_amount = 5
var/datum/delay_controller/next_run= new (10, 50)
/obj/machinery/computer/general_air_control/atmos_automation/New()
..()
for(var/i = 1, i <= register_amount, i++)//Fill the registers
@@ -93,6 +95,7 @@
out += "<a href=\"?src=\ref[src];on=1\" style=\"font-size:large;font-weight:bold;color:red;\">RUNNING</a>"
else
out += "<a href=\"?src=\ref[src];on=1\" style=\"font-size:large;font-weight:bold;color:green;\">STOPPED</a>"
out += " | <a href=\"?src=\ref[src];runonce=1\" style=\"font-size:large;font-weight:bold;color:green;\">RUN ONCE</a>"
out += "<p><a href=\"?src=\ref[src];view_assemblies=1\">View connected assemblies</a></p>"
@@ -158,6 +161,20 @@
investigation_log(I_ATMOS,"was turned [on ? "on" : "off"] by [key_name(usr)]")
return 1
if(href_list["runonce"])
if(next_run.blocked())
to_chat(usr, "<span class='warning'>You cannot Run Once too quickly, only once every 5 seconds.</span>")
return 0
on=FALSE
updateUsrDialog()
update_icon()
investigation_log(I_ATMOS,"was run once by [key_name(usr)]")
next_run.setDelay(5 SECONDS)
for(var/datum/automation/A in automations)
A.process()
to_chat(usr, "<span class='info'>Execution complete.</span>")
return 1
if(href_list["add"])
var/new_child=selectValidChildFor(null,usr,list(0))
if(!new_child)

View File

@@ -105,31 +105,37 @@ var/global/automation_types=typesof(/datum/automation) - /datum/automation
/datum/automation/proc/fmtString(var/str)
return str || "-----"
// TODO: Standardize this somewhere.
// This determines if a mob can send hrefs or other commands.
/datum/automation/proc/canWriteState(var/mob/user, var/href)
if(isobserver(user))
var/mob/dead/observer/O = user
var/ghost_flags = 0
if(parent.ghost_write)
ghost_flags |= PERMIT_ALL
if(canGhostWrite(O,parent,"",ghost_flags) || isAdminGhost(O))
if(!parent.custom_aghost_alerts)
log_adminghost("[key_name(user)] screwed with [parent] ([href])!")
return TRUE // Ghost is admin or otherwise allowed to dick with things.
return FALSE // Ghost is NOT admin? Bail.
if(user.incapacitated() || user.lying)
return FALSE // Lying down, or incapacitated.
if (!user.dexterity_check())
to_chat(user, "<span class='warning'>You don't have the dexterity to do this!</span>")
return FALSE
// Silicons can access shit from out of range.
if(istype(user, /mob/living/silicon))
return TRUE
// RAAAANGE CHEEEECK
return in_range(parent, user) && isturf(parent.loc)
/datum/automation/Topic(var/href, var/list/href_list)
var/ghost_flags = 0
if(parent.ghost_write)
ghost_flags |= PERMIT_ALL
if(!canGhostWrite(usr, parent, "", ghost_flags))
if(usr.restrained() || usr.lying || usr.stat)
return 1
if (!usr.dexterity_check())
to_chat(usr, "<span class='warning'>You don't have the dexterity to do this!</span>")
return 1
var/norange = 0
if(usr.mutations && usr.mutations.len)
if(M_TK in usr.mutations)
norange = 1
if(!norange)
if ((!in_range(parent, usr) || !istype(parent.loc, /turf)) && !istype(usr, /mob/living/silicon))
return 1
else if(!parent.custom_aghost_alerts)
log_adminghost("[key_name(usr)] screwed with [parent] ([href])!")
if(!canWriteState(usr, href))
return 1
if(href_list["add"])
var/new_child = selectValidChildFor(usr)
if(!new_child)
@@ -326,7 +332,8 @@ var/global/automation_types=typesof(/datum/automation) - /datum/automation
. += "<blockquote><i>(No statements to run)</i></blockquote>"
/datum/automation/if_statement/Topic(var/href, var/list/href_list)
. = ..(href, href_list - list("add", "remove", "reset")) // So we can do sanity but not make it trigger on these specific hrefs overriden with shitcode here.
if(..(href, href_list - list("add", "remove", "reset"))) // So we can do sanity but not make it trigger on these specific hrefs overriden with shitcode here.
return 1
if(href_list["add"])
var/new_child = selectValidChildFor(usr)
if(!new_child)