mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-30 11:32:20 +00:00
* Refactor, improve, and rename canUseTopic to be can_perform_action * updoot * https://github.com/tgstation/tgstation/pull/72876 https://github.com/tgstation/tgstation/pull/72876 --------- Co-authored-by: Tim <timothymtorres@gmail.com> Co-authored-by: Gandalf <9026500+Gandalf2k15@users.noreply.github.com>
69 lines
3.4 KiB
Plaintext
69 lines
3.4 KiB
Plaintext
/* CONTAINS:
|
|
* /obj/item/ai_module/core/freeformcore
|
|
* /obj/item/ai_module/supplied/freeform
|
|
**/
|
|
|
|
/obj/item/ai_module/core/freeformcore
|
|
name = "'Freeform' Core AI Module"
|
|
laws = list("")
|
|
|
|
/obj/item/ai_module/core/freeformcore/attack_self(mob/user)
|
|
var/targName = tgui_input_text(user, "Enter a new core law for the AI.", "Freeform Law Entry", laws[1], CONFIG_GET(number/max_law_len), TRUE)
|
|
if(!targName)
|
|
return
|
|
if(is_ic_filtered(targName))
|
|
to_chat(user, span_warning("Error: Law contains invalid text."))
|
|
return
|
|
var/list/soft_filter_result = is_soft_ooc_filtered(targName)
|
|
if(soft_filter_result)
|
|
if(tgui_alert(user,"Your law contains \"[soft_filter_result[CHAT_FILTER_INDEX_WORD]]\". \"[soft_filter_result[CHAT_FILTER_INDEX_REASON]]\", Are you sure you want to use it?", "Soft Blocked Word", list("Yes", "No")) != "Yes")
|
|
return
|
|
message_admins("[ADMIN_LOOKUPFLW(user)] has passed the soft filter for \"[soft_filter_result[CHAT_FILTER_INDEX_WORD]]\" they may be using a disallowed term for an AI law. Law: \"[html_encode(targName)]\"")
|
|
log_admin_private("[key_name(user)] has passed the soft filter for \"[soft_filter_result[CHAT_FILTER_INDEX_WORD]]\" they may be using a disallowed term for an AI law. Law: \"[targName]\"")
|
|
laws[1] = targName
|
|
..()
|
|
|
|
/obj/item/ai_module/core/freeformcore/transmitInstructions(datum/ai_laws/law_datum, mob/sender, overflow)
|
|
..()
|
|
return laws[1]
|
|
|
|
/obj/item/ai_module/supplied/freeform
|
|
name = "'Freeform' AI Module"
|
|
lawpos = 15
|
|
laws = list("")
|
|
|
|
/obj/item/ai_module/supplied/freeform/attack_self(mob/user)
|
|
var/newpos = tgui_input_number(user, "Please enter the priority for your new law. Can only write to law sectors 15 and above.", "Law Priority ", lawpos, 50, 15)
|
|
if(!newpos || QDELETED(user) || QDELETED(src) || !usr.can_perform_action(src, FORBID_TELEKINESIS_REACH))
|
|
return
|
|
lawpos = newpos
|
|
var/targName = tgui_input_text(user, "Enter a new law for the AI.", "Freeform Law Entry", laws[1], CONFIG_GET(number/max_law_len), TRUE)
|
|
if(!targName)
|
|
return
|
|
if(is_ic_filtered(targName))
|
|
to_chat(user, span_warning("Error: Law contains invalid text.")) // AI LAW 2 SAY U W U WITHOUT THE SPACES
|
|
return
|
|
var/list/soft_filter_result = is_soft_ooc_filtered(targName)
|
|
if(soft_filter_result)
|
|
if(tgui_alert(user,"Your law contains \"[soft_filter_result[CHAT_FILTER_INDEX_WORD]]\". \"[soft_filter_result[CHAT_FILTER_INDEX_REASON]]\", Are you sure you want to use it?", "Soft Blocked Word", list("Yes", "No")) != "Yes")
|
|
return
|
|
message_admins("[ADMIN_LOOKUPFLW(user)] has passed the soft filter for \"[soft_filter_result[CHAT_FILTER_INDEX_WORD]]\" they may be using a disallowed term for an AI law. Law: \"[html_encode(targName)]\"")
|
|
log_admin_private("[key_name(user)] has passed the soft filter for \"[soft_filter_result[CHAT_FILTER_INDEX_WORD]]\" they may be using a disallowed term for an AI law. Law: \"[targName]\"")
|
|
laws[1] = targName
|
|
..()
|
|
|
|
/obj/item/ai_module/supplied/freeform/transmitInstructions(datum/ai_laws/law_datum, mob/sender, overflow)
|
|
if(!overflow)
|
|
..()
|
|
else if(law_datum.owner)
|
|
law_datum.owner.replace_random_law(laws[1], list(LAW_SUPPLIED), LAW_SUPPLIED)
|
|
else
|
|
law_datum.replace_random_law(laws[1], list(LAW_SUPPLIED), LAW_SUPPLIED)
|
|
return laws[1]
|
|
|
|
/obj/item/ai_module/supplied/freeform/install(datum/ai_laws/law_datum, mob/user)
|
|
if(laws[1] == "")
|
|
to_chat(user, span_alert("No law detected on module, please create one."))
|
|
return 0
|
|
..()
|