From 6d4e2327a0e9485a485936bc98442e2de4176cf8 Mon Sep 17 00:00:00 2001 From: Bombermansam Date: Mon, 16 Jun 2025 16:44:19 -0400 Subject: [PATCH] Speech Components are now Multilingual (#4018) ## About The Pull Request You can now define a language for speech components to output in. They are no longer limited to just outputting strings in Galactic Common. This does not give access to ALL languages, for example Codespeak, Cultspeak and Ashtongue, so you will still need to earn the privilege to speak in those languages. ## Why It's Good For The Game Many people complained that speech components could only output in Galactic Common. This PR will make them happy. Speech components are most often used for Universal Translator Circuits, this PR will actually make them useful for such and allow for two way communication between individuals if the circuit is made correctly. ## Proof Of Testing It compiles and the valid languages were able to be observed while using the speech component.
Screenshots/Videos ![image](https://github.com/user-attachments/assets/d68e0a9f-5dcb-48f4-b804-6753f545d480) ![image](https://github.com/user-attachments/assets/aab4e882-453a-4722-afbe-639cf05cbd0e) ![image](https://github.com/user-attachments/assets/de756797-900d-41b4-9194-cdd42a19dfae) ![image](https://github.com/user-attachments/assets/fe1ef8ab-c8eb-470e-8516-58c27696a9a6) ![image](https://github.com/user-attachments/assets/45e7b7ea-2cce-4b65-9359-177a3bd014ee)
## Changelog :cl: add: Language Port to Speech Components /:cl: ## Acknowledgements Thank you very much to Artur for helping me make the list which was a pivotal part of this PR. I was tearing my hair out trying to make it. They saved me much time and hair. --- .../wiremod/components/action/speech.dm | 10 +---- .../wiremod/components/action/speech.dm | 45 +++++++++++++++++++ tgstation.dme | 1 + 3 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 modular_zubbers/code/modules/wiremod/components/action/speech.dm diff --git a/code/modules/wiremod/components/action/speech.dm b/code/modules/wiremod/components/action/speech.dm index 32495889faf..f149cba9122 100644 --- a/code/modules/wiremod/components/action/speech.dm +++ b/code/modules/wiremod/components/action/speech.dm @@ -9,8 +9,6 @@ category = "Action" circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL - /// Spans to apply to the output message. - var/datum/port/input/color_input // BUBBER ADDITION /// The message to send var/datum/port/input/message /// The quiet mode flag @@ -24,7 +22,6 @@ . += create_ui_notice("Speech Cooldown: [DisplayTimeText(speech_cooldown)]", "orange", "stopwatch") /obj/item/circuit_component/speech/populate_ports() - color_input = add_input_port("Color", PORT_TYPE_STRING, default = "Default") // BUBBER ADDITION message = add_input_port("Message", PORT_TYPE_STRING, trigger = null) quietmode = add_input_port("Quiet Mode", PORT_TYPE_NUMBER, default = 0) @@ -35,12 +32,7 @@ if(TIMER_COOLDOWN_RUNNING(parent.shell, COOLDOWN_CIRCUIT_SPEECH)) return - // BUBBER ADDITION - if(!(color_input.value in GLOB.component_span_color_list)) - color_input.set_value("Default", TRUE) - // BUBBER ADDITION END - if(message.value) var/atom/movable/shell = parent.shell - shell.say(message.value, forced = "circuit speech | [parent.get_creator()]", message_range = quietmode.value > 0 ? WHISPER_RANGE : MESSAGE_RANGE, spans = list(GLOB.component_span_color_list[color_input.value])) // BUBBER EDIT + shell.say(message.value, forced = "circuit speech | [parent.get_creator()]", message_range = quietmode.value > 0 ? WHISPER_RANGE : MESSAGE_RANGE) TIMER_COOLDOWN_START(shell, COOLDOWN_CIRCUIT_SPEECH, speech_cooldown) diff --git a/modular_zubbers/code/modules/wiremod/components/action/speech.dm b/modular_zubbers/code/modules/wiremod/components/action/speech.dm new file mode 100644 index 00000000000..8698a74bfc8 --- /dev/null +++ b/modular_zubbers/code/modules/wiremod/components/action/speech.dm @@ -0,0 +1,45 @@ +/obj/item/circuit_component/speech + /// The language setting + var/datum/port/input/language_port + + /// Spans to apply to the output message. + var/datum/port/input/color_input + + //Shell language selected from the list + var/shell_language + + //List of valid languages of the speech circuit + var/static/list/circuit_languages + +/obj/item/circuit_component/speech/Initialize(mapload) + . = ..() + if(!circuit_languages) + circuit_languages = list() + for(var/datum/language/language as anything in GLOB.language_datum_instances) + if(language.secret) + continue + circuit_languages[language.name] = language + +/obj/item/circuit_component/speech/populate_ports() + . = ..() + color_input = add_input_port("Color", PORT_TYPE_STRING, default = "Default") + language_port = add_input_port("Language", PORT_TYPE_STRING, trigger = null) + +/obj/item/circuit_component/speech/input_received(datum/port/input/port) + if(!parent.shell) + return + + if(TIMER_COOLDOWN_RUNNING(parent.shell, COOLDOWN_CIRCUIT_SPEECH)) + return + + if(!(color_input.value in GLOB.component_span_color_list)) + color_input.set_value("Default", TRUE) + + if(message.value) + var/atom/movable/shell = parent.shell + if (language_port.value in circuit_languages) //if user selected language is an [item] in the list then... + shell_language = circuit_languages[language_port.value] //selects the [value] for the specified [item] + else shell_language = /datum/language/common //if it is not in an [item] in the list then it defaults to common + shell.say(message.value, language = shell_language, forced = "circuit speech | [parent.get_creator()]", message_range = quietmode.value > 0 ? WHISPER_RANGE : MESSAGE_RANGE, spans = list(GLOB.component_span_color_list[color_input.value])) + TIMER_COOLDOWN_START(shell, COOLDOWN_CIRCUIT_SPEECH, speech_cooldown) + diff --git a/tgstation.dme b/tgstation.dme index c573813a5b5..0e31811bc45 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -9703,6 +9703,7 @@ #include "modular_zubbers\code\modules\voting\_votes.dm" #include "modular_zubbers\code\modules\voting\living_timer.dm" #include "modular_zubbers\code\modules\voting\vote_overrides.dm" +#include "modular_zubbers\code\modules\wiremod\components\action\speech.dm" #include "modular_zubbers\code\modules\wiremod\components\string\color.dm" #include "modular_zubbers\code\modules\wizard_dize\wizard_dice_event.dm" #include "modular_zubbers\code\modules\wizard_dize\wizard_dice_object.dm"