From 78a9c619526db46e25cb20d243cdb6f58d18f70f Mon Sep 17 00:00:00 2001 From: Putnam3145 Date: Mon, 12 Oct 2020 04:26:18 -0700 Subject: [PATCH] Makes dwarf text not check every replacement every time. (#13346) * Makes dwarf text not check every replacement every time. * Apply suggestions from code review Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> --- .../carbon/human/species_types/dwarves.dm | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/code/modules/mob/living/carbon/human/species_types/dwarves.dm b/code/modules/mob/living/carbon/human/species_types/dwarves.dm index ce67a947de..7c35ade4f2 100644 --- a/code/modules/mob/living/carbon/human/species_types/dwarves.dm +++ b/code/modules/mob/living/carbon/human/species_types/dwarves.dm @@ -51,17 +51,18 @@ GLOBAL_LIST_INIT(dwarf_last, world.file2list("strings/names/dwarf_last.txt")) // //Dwarf Speech handling - Basically a filter/forces them to say things. The IC helper /datum/species/dwarf/proc/handle_speech(datum/source, list/speech_args) var/message = speech_args[SPEECH_MESSAGE] - if(speech_args[SPEECH_LANGUAGE] != /datum/language/dwarf) // No accent if they speak their language - if(message[1] != "*") - message = " [message]" //Credits to goonstation for the strings list. - var/list/dwarf_words = strings("dwarf_replacement.json", "dwarf") //thanks to regex too. - for(var/key in dwarf_words) //Theres like 1459 words or something man. - var/value = dwarf_words[key] //Thus they will always be in character. - if(islist(value)) //Whether they like it or not. - value = pick(value) //This could be drastically reduced if needed though. - message = replacetextEx(message, " [uppertext(key)]", " [uppertext(value)]") - message = replacetextEx(message, " [capitalize(key)]", " [capitalize(value)]") - message = replacetextEx(message, " [key]", " [value]") //Also its scottish. + if(speech_args[SPEECH_LANGUAGE] != /datum/language/dwarf && message[1] != "*") // No accent if they speak their language + message = " [message]" //Credits to goonstation for the strings list. + var/list/dwarf_words = strings("dwarf_replacement.json", "dwarf") //thanks to regex too. + for(var/word in splittext(message," ")) + var/value = dwarf_words[word] //Thus they will always be in character. + if(!value) + continue + if(islist(value)) //Whether they like it or not. + value = pick(value) //This could be drastically reduced if needed though. + message = replacetextEx(message, " [uppertext(word)]", " [uppertext(value)]") + message = replacetextEx(message, " [capitalize(word)]", " [capitalize(value)]") + message = replacetextEx(message, " [word]", " [value]") //Also its scottish. if(prob(3)) message += " By Armok!"