Can you add support for commas?
Massive Update!
Complete rewrite and refactor
This update exposes all the properties of a TextLabel as top-level members of Spinner. This means that you no longer have to do Spinner.Frame.Size
but rather just Spinner.Size
! Much cleaner. it also means that all the properties are supported instead of just font, size, and color. Now you can have textstrokes and stuff too!
This update also adds a new creator method: NumberSpinner.fromGuiObject(GuiObject)
! This will create a Spinner and automatically apply the properties of the passed GuiObject. If the GuiObject is a TextObject, it will also apply the text related properties.
Iâve added a setting Spinner.Commas
as per @AlreadyProâs request.
Iâve also added Spinner.Suffix
which is the same as prefix but at the end.
Iâve added support for negative values (somehow we never noticed that negative values errored?) so that works now!
For some reason itâs not changing the decimal symbol to comma.
Anyway, what a great, unambiguous, explicit and featured API, itâs more explicit and less ambiguous than ICUâs API I say. I totally was confused by ICUâs API. Letâs switch from groupingStrategy
to Commas
. Also letâs switch from âAUTOâ, âOFFâ, âMIN2â, âON_ALIGNEDâ and âTHOUSANDSâ to booleans for this, totally gave me more option and is less ambiguous. Letâs default this value to false
instead of being notation sensitive (MIN2 for compact, AUTO for everything else). Thanks for the inspiration /s
In seriousness, maybe have a less ambiguous name than âcommasâ?
and still errors for other IEEE 754 values like Infinites & NaNs which I pointed out. Maybe a more friendly error message for values like this?
Checking the source code.
local isNegative = Spinner.Value < 0
Whatâs this amazing algorithm you got there? Youâre very talented indeed. You found a new way to check for signed value.
Now instead of dividing by the value just to see if itâs Infinity/-Infinity if it equals to 0 and checking for sign bit for NaNs, I could now check for negative NaN (no difference between a positive NaN except visual and sign bit manipulation) using this algorithm. Thanks to this feature, I learnt that the -
sign suddenly disappeared when a floating point underflow has occurred, 1 divided by value totally doesnât return signed Infinity but positive Infinity /s.
In seriousness this doesnât account for signed 0 which Iâm not sure if itâs also intentional, (though floats close to signed 0 like -1e-100
returns signed 0).
Is this also intended to be an alternative for the NumberFormatter
from ICU? With âCommasâ and Currencies added, itâs kinda feels like it sans i18n-related stuff.
Nice looking NumberSpinners! Well, as I am a person who makes visualization, I used to make it onceâŚ
https://i.gyazo.com/4fc0fb6156b8fc5daf7b6535d7ff301b.mp4
But itâs looking pretty neat. Nice one!
Is it possible to reverse the transition from a 10 â 9?
Show in this GIF, my timer counts down from 10 to 0, but the first transition has it go from 10 â 0 â all the way back to 9 which makes it look odd compared to the following transitions
If you do feel like updating this, a setting called something like ReverseOnDigitChange
(idk) would be cool
https://gyazo.com/c2ea9978a243fdf7365389b40a5cf6d2
This module does not seem to work with the TextScaled property. From my own tests when creating a new spinner object with .fromGuiObject the text size will be whatever size is set in the text properties.
Likewise, when trying to manually set the TextScaled property to true via mySpinner.TextScaled = true also does not scale the text to the frame size. (Obviously, if you look at the instance created in the playerGui you will see this wouldnât work)
Unless I am getting something wrong, this isnât usable as-is if you want your game to be viewable on a wide variety of screen sizes, such as phones.
On that note, does anyone know how to make this work wth scaled text and/or know of another module that can do this with scaled text?
Your comment inspired me to recreate that game the next night, and then I completely forgot to mention or release it lol
The game is now a nice example of this module being used in a full game environment!
https://www.roblox.com/games/6528148945/Money-Makin-Machine
This Spinner Module is pretty nice, but there is one problem. The fromGuiObject function doesnât work as I expected, the UI Gradient inside the original GuiObject doesnât get added in the Spinner, the sizing gets very altered and some digits dont have the same stroke configuration as the original GuiObject (some digits have a stroke and some donât).
How would I use this to create a clock and be able to have a :
so I could have it in a usual time format.
How can I make this work with Roact?
A great addition that is similar to Decimals/Commas would be to be able to support time string so we can do things like a timer:
â2:00â
â1:59â
â0:30â
Other than that, nice module.
Nice module! Itâs such a good module for little touches in your game. Canât wait to see what comes next!
Pretty neat module, but had a question. Is there a way to remove the .00
after the actual number? Itâs a little annoying.
EDIT: Nevermind, just figured it out that you can remove it by setting Decimals to 0.
Pretty Cool Module but why are the numbers so small?
second pic is the size I would want it to be
code is just basically this:
local NumberSpinner = require(script:WaitForChild("NumberSpinner"))
local Frame = script.Parent:WaitForChild("Frame")
local Spinner = NumberSpinner.fromGuiObject(Frame.TextLabel)
Spinner.Decimals = 0
Spinner.Parent = Frame
while wait(0.5) do
Spinner.Value = math.random(1,1000000)
end
any help will do!
I dont think it works with the TextScaled property.
do you know how to make the spinner bigger?
Just set the TextLabelâs TextSize property to a bigger number?
Wait can anyone explain how I can set this up? Iâm a lil confused
Hello, I just have a few questions.
- How can i make it use an already existing label, if that is even possible
- What am i doing wrong here -
local Players = game:GetService("Players")
local Replicated = game:GetService("ReplicatedStorage")
local Player = Players.LocalPlayer
local Cash = Player:WaitForChild("leaderstats").Cash
local Label = script.Parent
local NumberSpinner = require(Replicated:WaitForChild("NumberSpinner"))
local PriceSpinner = NumberSpinner.new()
PriceSpinner.Decimals = 0
PriceSpinner.Duration = 0.25
PriceSpinner.Parent = Label
Cash.Changed:Connect(function()
PriceSpinner.Value =("$"..Cash.Value)
end)
Just throws this
Attempted to set Spinner.Value to invalid value ($49)
Value needs to be a number, not a string. You can set the spinner prefix to $ if youâd like.