[MIRROR] Improves AI Law Module Examining [MDB IGNORE] (#15905)

* Improves AI Law Module Examining (#69475)

* Improves AI Law Module Examining

Hey there,

The old version of checking to see what AI laws were on a board were just ugly. They were in a proc completely separate from the actual Examine, and the to_chat utilization it used meant that ghosts couldn't see it (since they didn't count as mob/user i believe). So, let's use examine blocks, make the implementation cleaner in the examine (and actually make it ordered too!).

* Addresses Review + File Organization

Cleans up comments, compresses lines of code.

I also moved the handle_unique_ai() proc below all the examine/attack/display_laws procs to give it some sense of grouping.

* i accidentally deleted the whole line

* Update code/game/objects/items/AI_modules/_AI_modules.dm

real

Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com>

Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com>

* Improves AI Law Module Examining

Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com>
This commit is contained in:
SkyratBot
2022-08-30 02:20:12 +02:00
committed by GitHub
parent 96ea3267e1
commit d69f2b4db2
@@ -30,23 +30,29 @@
/obj/item/ai_module/examine(mob/user as mob)
. = ..()
if(Adjacent(user))
show_laws(user)
var/examine_laws = display_laws()
. += "\n" + examine_laws
/obj/item/ai_module/attack_self(mob/user as mob)
..()
show_laws(user)
to_chat(user, examine_block(display_laws()))
/// Returns a text display of the laws for the module.
/obj/item/ai_module/proc/display_laws()
// Used to assemble the laws to show to an examining user.
var/assembled_laws = ""
if(laws.len)
assembled_laws += "<B>Programmed Law[(laws.len > 1) ? "s" : ""]:</B><br>"
for(var/law in laws)
assembled_laws += "\"[law]\"<br>"
return assembled_laws
///what this module should do if it is mapload spawning on a unique AI station trait round.
/obj/item/ai_module/proc/handle_unique_ai()
return SHOULD_QDEL_MODULE //instead of the roundstart bid to un-unique the AI, there will be a research requirement for it.
/obj/item/ai_module/proc/show_laws(mob/user as mob)
if(laws.len)
to_chat(user, "<B>Programmed Law[(laws.len > 1) ? "s" : ""]:</B>")
for(var/law in laws)
to_chat(user, "\"[law]\"")
//The proc other things should be calling
/obj/item/ai_module/proc/install(datum/ai_laws/law_datum, mob/user)
if(!bypass_law_amt_check && (!laws.len || laws[1] == "")) //So we don't loop trough an empty list and end up with runtimes.