|
Post by temp on Aug 17, 2020 18:33:05 GMT
Hello
I'd like to use the english_number (and variants) parameters, but in my locale. Where is it defined so I could append my <locale>_number ?
Thanks.
|
|
|
Post by cajun on Aug 18, 2020 3:20:43 GMT
Hello I'd like to use the english_number (and variants) parameters, but in my locale. Where is it defined so I could append my <locale>_number ? Thanks.
i think this is defined in the executable, so you'd need to write out a script in magic.mse-game/script the brute force method would be to have an array of all the numbers, starting with 0, like this:
spanish_number := { espanol_array := ["cero", "uno", "dos", "tres", "cuatro", "cinco", "seis", "siete", "ocho", "nueve", "diez"] if input > 10 then input ##if it's bigger than our script handles, return the number else espanol_array[input] }
then doing spanish_number(1) would return "uno". this might be all you need, but i'mma go another step, cause it'll be nice to have if nothing else. if your language has a nice algorithmic counting you can more easily count up higher without having to type everything out. spanish isn't the friendliest here; it has unique names to 15, one algorithm from 16-29, then another for 30-99, so we'll add an extra step to account for that in a script to get to 99: spanish_number := { ## first, the number arrays espanol_ones_array := ["cero", "uno", "dos", "tres", "cuatro", "cinco", "seis", "siete", "ocho", "nueve", "diez", "once", "doce", "trece", "catorce", "quince"] espanol_tens_array := ["cero", "diec", "viente", "treinta", "cuarenta", "cincuenta", "sesenta", "setenta", "ochenta", "noventa"] ## then calc our ones and tens ones := input mod 10 tens := (input - ones) / 10 ## since one of our options is pretty complicated, we separate this into three separate functions we might execute function_map := [ small: {espanol_ones_array[input]}, large: { final_answer := espanol_tens_array[tens] + " y " + espanol_ones_array[ones] final_answer := replace(final_answer, match:" y cero", replace:"") ##remove redundant "and zero" final_answer := replace(final_answer, match:"(diec|vient)e? y ", replace:"\\1i") ##16-29 are one word final_answer }, oversized: {input} ] ## then depending on the input, we execute the right function if input < 16 then function_map["small"]() else if input < 100 then function_map["large"]() else function_map["oversized"]() } then we can check our work...
and should be good to go!
|
|
|
Post by temp on Aug 18, 2020 9:01:08 GMT
Thanks
It works fine in console, but when used for reminder text I got an error
{spanish_number(param1)}
Can't convert "<param-number><atom-kwpph>number</atom-kwpph></param-number>" from keyword parameter to integer number in function spanish_number
Whereas {english_number(param1)} works fine. param1 is a "<number>" (used with "myKeyword <number>")
I tried to use functions like to_int(param1), to_int(param1.value), in the reminder but there is always a convert error.
Any idea ?
Thanks
|
|
|
Post by cajun on Aug 18, 2020 12:41:07 GMT
Thanks It works fine in console, but when used for reminder text I got an error {spanish_number(param1)}
Can't convert "<param-number><atom-kwpph>number</atom-kwpph></param-number>" from keyword parameter to integer number in function spanish_number
Whereas {english_number(param1)} works fine. param1 is a "<number>" (used with "myKeyword <number>") I tried to use functions like to_int(param1), to_int(param1.value), in the reminder but there is always a convert error. Any idea ? Thanks huh, guess it's trying to run it on the template code and not just on the actual cards. k, that needs three changes then, first we need to remove the tags with "input := remove_tags(input)", move the ones and tens declarations inside function_map["large"] (the only place we needed them anyway), and add a do-nothing step for the word number, 'if input = "number" then ""', so the final thing looks like this, and looks to be working in reminder text:
spanish_number := { input := remove_tags(input) espanol_ones_array := ["cero", "uno", "dos", "tres", "cuatro", "cinco", "seis", "siete", "ocho", "nueve", "diez", "once", "doce", "trece", "catorce", "quince"] espanol_tens_array := ["cero", "diec", "viente", "treinta", "cuarenta", "cincuenta", "sesenta", "setenta", "ochenta", "noventa"] function_map := [ small: {espanol_ones_array[input]}, large: { ones := input mod 10 tens := (input - ones) / 10 final_answer := espanol_tens_array[tens] + " y " + espanol_ones_array[ones] final_answer := replace(final_answer, match:" y cero", replace:"") ##remove redundant "and zero" final_answer := replace(final_answer, match:"(diec|vient)e? y ", replace:"\\1i") ##16-29 are one word final_answer }, oversized: {input} ] if input = "number" then "" else if input < 16 then function_map["small"]() else if input < 100 then function_map["large"]() else function_map["oversized"]() }
|
|
|
Post by temp on Aug 18, 2020 20:27:31 GMT
Thanks. It works perfectly.
The next step we might want is to write this in a separate file and provide it in a package to other users which would like to install it on their own MSE.
What do you think?
|
|
|
Post by cajun on Aug 18, 2020 21:43:58 GMT
Thanks. It works perfectly.
The next step we might want is to write this in a separate file and provide it in a package to other users which would like to install it on their own MSE.
What do you think? probably the best bet for a wider release would be to have it as an update to the magic.mse-game/language file; for now that would just be adding the code there like it was in the script file, but if you had the full localization stuff we could set up general "number_word(), number_word_a()" etc functions that use the proper language function based on the set's language.
|
|
|
Post by temp on Aug 19, 2020 19:31:54 GMT
Why not in <locale>.mse-locale ? So that only people interested but some locale get the updated version. By the way, where is MSE source code repository in order to create pull requests?
|
|
|
Post by cajun on Aug 20, 2020 1:23:39 GMT
Why not in <locale>.mse-locale ? So that only people interested but some locale get the updated version. By the way, where is MSE source code repository in order to create pull requests?
<locale>.mse-locale, as far as I can tell, only sets the words and keyboard shortcuts built into the client. if the script is put here and tested, it gives an error message.
|
|