|
| 15 Oct 2016 10:35 PM |
I want to get a more realistic timer for songs.. But I'm not sure how to do it.
Percentage.Text = Percentage.Text:format("%d:%d", math.floor((Lazerus.TimePosition / 60), Lazerus.TimeLength % 60))
~ Add 5k+ Posts ~{ Previous Name: i_Movie } |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 10:54 PM |
Percentage.Text = string.format("%d0 : %d", (Lazerus.TimePosition/Lazerus.TimeLength), (Lazerus.TimeLength))
~ Add 5k+ Posts ~{ Previous Name: i_Movie } |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 10:57 PM |
Can't figure it out... :/
~ Add 5k+ Posts ~{ Previous Name: i_Movie } |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 10:57 PM |
local currentTime = 1200 print(string.format("%.2d:%.2d", math.floor(currentTime / 60),currentTime % 60))
pattern for formatting of 2 integers |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 10:59 PM |
here is another example:
for currentTime=0,2000 do print(string.format("%.2d:%.2d", math.floor(currentTime / 60),currentTime % 60)) wait(0.2) end
|
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 11:01 PM |
I'm not using values though.. I'm using an audio..
~ Add 5k+ Posts ~{ Previous Name: i_Movie } |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 11:04 PM |
Are you being serious?
Do you not understand what a value is?
Or how lua works at all?
I just used an example variable so it literally does not matter -.- |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 11:06 PM |
*face-palm*
All I have to say to be honest...
~ Add 5k+ Posts ~{ Previous Name: i_Movie } |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 11:07 PM |
Also, I don't know string manipulation or math in Lua, so it's clearly not my fault that I made myself look like an idiot here.
~ Add 5k+ Posts ~{ Previous Name: i_Movie } |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 11:08 PM |
Just for future reference:
The TimePosition is a number, so is currentTime, so it should work the same way since they are both numbers. It would work on decimal numbers too because d is for ints |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 11:13 PM |
Also still confused about to do this..
Here's what I'm trying to do:
1. Get the song's time length in minute format
2. While the song is playing, it counts up
Example:
TimeLength = 2:00 -- Minute Format
The number would start at 00:00 and count up to 2 minutes. But you see, I don't know string maniulation at all and I honestly just tried looking it up and I honestly have no idea how to do it so.. I'm out of luck I think unless someone is nice enough to show me how it's done.
~ Add 5k+ Posts ~{ Previous Name: i_Movie } |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 11:14 PM |
| Simply get rid of the .2 in the first digit or change it to .1 |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 11:14 PM |
*About how to do this
Am tired rn.
~ Add 5k+ Posts ~{ Previous Name: i_Movie } |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 11:18 PM |
It is pretty easy...
d in format is formatting a number into an integer
combining %_d with another integer creates space in front of it that can fill up using a decimal number adds 0s for each empty space
f in format is a float number %_f with an integer does the same as when using %_d with an int with a decimal it increases the amount of decimal points and rounds them up |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 11:23 PM |
Easy for you, not for me.
Tried doing what you just did in the script and it said it's not a valid format option.
~ Add 5k+ Posts ~{ Previous Name: i_Movie } |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 11:30 PM |
for currentTime=0,200 do print(string.format("%d:%.2d", math.floor(currentTime / 60),currentTime % 60)) wait(0) end
. ___ . |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 11:35 PM |
| You can also do more things with audio now such as getting playback volume and using new effects, look up SoundEffects on the wiki and there is also something like :GetPlaybackVolume or something |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 11:40 PM |
Oh really? I couldn't find anything.
~ Add 5k+ Posts ~{ Previous Name: i_Movie } |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 11:42 PM |
| http://wiki.roblox.com/index.php?title=API:Class/SoundEffect |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2016 11:44 PM |
Oh, I was looking at the wrong api.
~ Add 5k+ Posts ~{ Previous Name: i_Movie } |
|
|
| Report Abuse |
|
|