mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-12 18:51:53 +00:00
## About The Pull Request Fixes #82440 This PR just creates a new macro, `LOWER_TEXT()` (yes the irony is not lost on me) to wrap around all calls of `lowertext()` and ensure that whatever we input into that proc will be stringified using the `"[]"` (or `tostring()` for the nerds) operator. very simple. I also added a linter to enforce this (and prevent all forms of regression) because I think that machines should do the menial work and we shouldn't expect maintainers to remember this, let me know if you disagree. if there is a time when it should be opted out for some reason, the linter does respect it if you wrap your input with the `UNLINT()` function.
52 lines
1.3 KiB
Plaintext
52 lines
1.3 KiB
Plaintext
#define COMP_TEXT_LOWER "To Lower"
|
|
#define COMP_TEXT_UPPER "To Upper"
|
|
|
|
/**
|
|
* # Text Component
|
|
*
|
|
* Either makes the text upper case or lower case.
|
|
*/
|
|
/obj/item/circuit_component/textcase
|
|
display_name = "Text Case"
|
|
desc = "A component that makes its input uppercase or lowercase."
|
|
category = "String"
|
|
|
|
var/datum/port/input/option/textcase_options
|
|
|
|
/// The input port
|
|
var/datum/port/input/input_port
|
|
|
|
/// The result of the text operation
|
|
var/datum/port/output/output
|
|
|
|
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
|
|
|
|
/obj/item/circuit_component/textcase/populate_options()
|
|
var/static/component_options = list(
|
|
COMP_TEXT_LOWER,
|
|
COMP_TEXT_UPPER,
|
|
)
|
|
textcase_options = add_option_port("Textcase Options", component_options)
|
|
|
|
/obj/item/circuit_component/textcase/populate_ports()
|
|
input_port = add_input_port("Input", PORT_TYPE_STRING)
|
|
output = add_output_port("Output", PORT_TYPE_STRING)
|
|
|
|
/obj/item/circuit_component/textcase/input_received(datum/port/input/port)
|
|
|
|
var/value = input_port.value
|
|
if(isnull(value))
|
|
return
|
|
|
|
var/result
|
|
switch(textcase_options.value)
|
|
if(COMP_TEXT_LOWER)
|
|
result = LOWER_TEXT(value)
|
|
if(COMP_TEXT_UPPER)
|
|
result = uppertext(value)
|
|
|
|
output.set_output(result)
|
|
|
|
#undef COMP_TEXT_LOWER
|
|
#undef COMP_TEXT_UPPER
|