From d69f2b4db25b2beb06d19a29f6c4ff09f86ea933 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 30 Aug 2022 02:20:12 +0200 Subject: [PATCH] [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 Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com> --- .../objects/items/AI_modules/_AI_modules.dm | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/code/game/objects/items/AI_modules/_AI_modules.dm b/code/game/objects/items/AI_modules/_AI_modules.dm index df9e5150da0..853bebe9db6 100644 --- a/code/game/objects/items/AI_modules/_AI_modules.dm +++ b/code/game/objects/items/AI_modules/_AI_modules.dm @@ -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 += "Programmed Law[(laws.len > 1) ? "s" : ""]:
" + for(var/law in laws) + assembled_laws += "\"[law]\"
" + + 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, "Programmed Law[(laws.len > 1) ? "s" : ""]:") - 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.