reverse ZO_LocalizeDecimalNumber ?
is there a built in function to return 10,000 back to 10000 something like ZO_LocalizeDecimalNumber?
|
Quote:
tonumber(value) ? |
Quote:
|
Doesn't appear to work.
It's not critical but I prefer to have numbers in 10,000 format for asthetics. numbers like 10000 in a dropdown looks cheese. Its just for a new telvar reserve feature for Xmultiplier telvar farming but want it to look guud =p. Its perfectly functional now without comma. ill continue with no comma for now unless we find something genius. its basically this line that needs the tweak to non comma delimited number like 10000: Code:
setFunc = function(var) MyAddon.savedVariables.telvarReserve = tonumber(var) end, |
If you want to remove the delimiter it should be enough to use tonumber function.
But if you want to save and show it differently you cannot use both, with delimiter and without in your same 1 SavedVars variable! Your SavedVars should save with tonumber and your getFunc needs to convert the visual parts to show with the delimiter then (get SV, convert to with delimiter, return in getFunc). And in setFunc do the opposite. |
Quote:
ive tried: Code:
choices = {"0", "100", "1,000", "10,000"}, **EDIT Hmm maybe i'll just save the variables with commas and use the tonumber once in the banking code to convert it back there.. unless u can think of another way to format the "choices" line |
I really recommend against mixing formats like that. Anything can be stored at a number like 10000 or 1000 anywhere you want. For a table for LibAddonMenu, in the saved variables, anything. When displaying the number then use the zo_xxx function. Otherwise you will be going back and forth all over the place. For example comparing 10,000 vs 10000 and so on.
Another thing though is if the value is not going to change then use a constant local YOURMODNAME_VALUE_TEN_THOUSAND = 10000 Code:
choices = {"0", "100", "1,000", ZO_LocalizeDecimalNumber(YOURMODNAME_VALUE_TEN_THOUSAND) }, |
Also go to an online Lua compiler
Code:
local value = "10,000" Code:
local value = "10,000" Code:
local value = "10,000" Also you probably want to use Regex because that will only work for English with a comma. It won't work for any foreign number with a period for the separator. Code:
local value = "10.000" |
Quote:
Ive currently left it as 10000 everywhere and working fine. Just looks like crap in the settings imo. |
My second post shows how to go back and forth though, did you get a chance to try that?
|
Use choices and choicesValues! I described that in my other post of you in detail already.
|
The choices & choicesValues worked perfectly :). I tried some of Sharlikrans stuff but was having issues with the setfunction saving those functions as well which wasn't playing nice with the banking code.
|
Note: there's an expectation with ZO_CommaDelimitNumber and ZO_CommaDelimitDecimalNumber that the result would at some point make its way into a grammar call in an arg of the format <<f:1>>, because grammar will automatically convert the , and . to the appropriate delimiter for the user's language (some languages swap the . and the , from what English uses. French, I believe, uses hardspaces.) ZO_FastFormatDecimalNumber uses already localized delimiters so you can skip the call to grammar.
All that to say make sure you know whether the string you're working with is before or after being localized. Because if it's after, just using gsub to replace ',' with '' will replace the decimal, not the thousands separators, in some languages. If it's after localization, consider using GetString(SI_DIGIT_GROUP_SEPARATOR) for your gsub. |
Quote:
|
Moved your thread and some others to lua / xml questions. Please use this forum in the future if you got general questions about coding, instead of the addon help forum which is there for addon related questions or to get help with an addon (non devs). Thank you
|
Quote:
|
Addon help forums is for users asking questions about addons or installing addons, non working addons etc. and not about developers asking for coding instructions and help to code their addons. Therefor you (and other threads I moved :-) ) got the authoring discussion (The place to ask general questions about developing AddOns) and the lua/XML help ( The place to ask specific questions about lua development) forums.
|
Quote:
|
All times are GMT -6. The time now is 10:54 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI