Пользовательские дополнения
На главную
common.FormatNumber( value, format )
Преобразует число в строку в заданном формате. Результат возвращается в виде локализуемой строки.
-- библиотека:
сommon
-- объявление:
function FormatNumber( value, format )
-- параметры:
value: Number - исходное число
format: String or nil - строка с форматом, имеет вид: "+12.3[4]A5" [sign][width][.precision][[total]][abbreviate], где
sign - флаг, задается символом +, отвечает за вывод знака положительного числа, отрицательные числа всегда выводятся со знаком; по умолчанию не задан
width - минимальная длина целой части числа, недостающие разряды в целой части числа будут заменены символом 0; по умолчанию 1
.precision - максимальное число знаков после десятичной точки; десятичная точка может быть задана символом '.' или ','; по умолчанию 2
[total] - максимальное число знаков в итоговом числе, не считая десятичной точки и знаков аббревиации; не влияет на вывод целой части; по умолчанию не задан
abbreviate - аббревиация числа, задается в виде "An", где n - номер разряда числа, начиная с которого число будет подвержено аббревиации
-- возвращаемые значения:
WString - текстовое представление исходного числа в указанном формате
-- примеры:
local valueText = common.FormatNumber( value, "+.2[3]A5" )
common.FormatNumber( 1234, ".2A4" ) == "1.23K"
common.FormatNumber( 1234, ".2A5" ) == "1234"
common.FormatNumber( 12345, "[3]A5" ) == "12.3K"
common.FormatNumber( 0.123, "+.2" ) == "+0.12"
common.FormatNumber( -1.234, "+.2" ) == "-1.23"
common.FormatNumber( 12.345, ".2[3]" ) == "12.3"
common.FormatNumber( -123.45, ".2[3]" ) == "-123"
Search: "CategoryLuaApi" "CategoryCommon"
CategoryCommon
EnumAddonState
EnumGoalState
EventAddonLoadStateChanged
EventAllodsGoalAdded
EventAllodsGoalChanged
EventAllodsGoalCompleted
EventFullscreenChanged
EventLocaleChanged
EventPosConverterChanged
EventUserScreenshot
FunctionApitype
FunctionCommonCreateValuedObject
FunctionCommonCreateValuedText
FunctionCommonDisablePersonalEvent
FunctionCommonEnablePersonalEvent
FunctionCommonEnableUIRender
FunctionCommonFormatFloat
FunctionCommonFormatInt
FunctionCommonFormatNumber
FunctionCommonGetAbsTimeMs
FunctionCommonGetAddonInfo
FunctionCommonGetAddonMainForm
FunctionCommonGetAddonName
FunctionCommonGetAddonSysName
FunctionCommonGetAllodsGoals
FunctionCommonGetAllodsGoalsOnLoadingScreen
FunctionCommonGetApiType
FunctionCommonGetApiVersion
FunctionCommonGetClientArch
FunctionCommonGetCredits
FunctionCommonGetCSSList
FunctionCommonGetDateTimeFromMs
FunctionCommonGetEmptyWstring
FunctionCommonGetFatalityPhraseLimits
FunctionCommonGetFirstPaymentBonusInfo
FunctionCommonGetFPSData
FunctionCommonGetLocalDateTime
FunctionCommonGetLocalDateTimeMs
FunctionCommonGetLocale
FunctionCommonGetLocaleList
FunctionCommonGetLocalization
FunctionCommonGetMks
FunctionCommonGetMsFromDateTime
FunctionCommonGetPosConverterParams
FunctionCommonGetRandFloat
FunctionCommonGetRandInt
FunctionCommonGetScriptCfgVar
FunctionCommonGetSetBonusInfo
FunctionCommonGetShortString
FunctionCommonGetSpecialStatInfo
FunctionCommonGetStateManagedAddons
FunctionCommonGetStateName
FunctionCommonGetTerritoryInfo
FunctionCommonGetTextureInfo
FunctionCommonGetTextureSize
FunctionCommonHitFrameHandler
FunctionCommonIsAvatarNameValid
FunctionCommonIsCapsLockEnabled
FunctionCommonIsEmptyValuedText
FunctionCommonIsEmptyWstring
FunctionCommonIsEqualStats
FunctionCommonIsFatalityPhraseFiltered
FunctionCommonIsKeyEnabled
FunctionCommonIsOnPayToPlayShard
FunctionCommonIsSoundEnabled
FunctionCommonIsSubstring
FunctionCommonIsSubstringEx
FunctionCommonIsTextFiltered
FunctionCommonIsUIRenderEnabled
FunctionCommonIsValidText
FunctionCommonIsValuedObject
FunctionCommonIsValuedText
FunctionCommonIsWidget
FunctionCommonIsWString
FunctionCommonLogError
FunctionCommonLogInfo
FunctionCommonLogWarning
FunctionCommonMakeUserScreenshot
FunctionCommonOnEvent
FunctionCommonOnFrame
FunctionCommonOnReaction
FunctionCommonQuitGame
FunctionCommonRegisterEventHandler
FunctionCommonRegisterFrameHandler
FunctionCommonRegisterReactionHandler
FunctionCommonSendEvent
FunctionCommonSendUserModsEvent
FunctionCommonSetCursor
FunctionCommonSetIconFlash
FunctionCommonSetLocale
FunctionCommonStateLoadManagedAddon
FunctionCommonStateReloadManagedAddon
FunctionCommonStateUnloadManagedAddon
FunctionCommonUnRegisterEvent
FunctionCommonUnRegisterEventHandler
FunctionCommonUnRegisterFrameHandler
FunctionCommonUnRegisterReaction
FunctionCommonUnRegisterReactionHandler
FunctionCompareWString
FunctionCompareWStringEx
FunctionEscapeWString
FunctionGlobal
FunctionIsIndexableUdata
GoalId
Search: "CategoryLuaApi" "CategoryValuedText"
CategoryValuedText
EventValuedObjectClicked
EventValuedObjectDoubleClicked
EventValuedObjectMouseOver
FunctionAvatarGetAbilityValuedObject
FunctionAvatarGetBuffValuedObject
FunctionAvatarGetGlossaryDescription
FunctionCommonCreateValuedObject
FunctionCommonCreateValuedText
FunctionCommonFormatFloat
FunctionCommonFormatInt
FunctionCommonFormatNumber
FunctionCommonIsEmptyValuedText
FunctionCommonIsValuedObject
FunctionCommonIsValuedText
FunctionItemLibGetValuedObject
FunctionMountGetValuedObject
FunctionSpellLibGetValuedObject
FunctionTextViewSetValuedText
FunctionUnitGetPlayerValuedObject
FunctionUnitGetUnitValuedObject
FunctionValuedObjectGetId
FunctionValuedObjectGetImage
FunctionValuedObjectGetShardName
FunctionValuedObjectGetText
FunctionValuedObjectGetType
FunctionValuedTextClearValues
FunctionValuedTextCreateCopy
FunctionValuedTextHasObjects
FunctionValuedTextIsEmpty
FunctionValuedTextSetClassVal
FunctionValuedTextSetFormat
FunctionValuedTextSetPlainText
FunctionValuedTextSetTagAttributes
FunctionValuedTextSetTextValues
FunctionValuedTextSetVal
FunctionValuedTextToWString
TypeValuedObject
TypeValuedText
CategoryLuaApi
CategoryFunction
CategoryCommon
CategoryValuedText
На главную