megaman54 Posted September 6, 2011 Share Posted September 6, 2011 How to covert milliseconds to seconds? Link to comment
megaman54 Posted September 6, 2011 Author Share Posted September 6, 2011 What function is that? Link to comment
JR10 Posted September 6, 2011 Share Posted September 6, 2011 What? Just divide the milliseconds. milliseconds / 1000 Link to comment
NotAvailable Posted September 6, 2011 Share Posted September 6, 2011 Minutes: http://www.calculateme.com/Time/Minutes ... econds.htm Seconds: http://www.calculateme.com/Time/Millise ... econds.htm Link to comment
megaman54 Posted September 6, 2011 Author Share Posted September 6, 2011 Yes, but i need the script to calculate it. I mean, i type a command like this: /calc then it outputs that in seconds. What function should i use for this? Link to comment
JR10 Posted September 6, 2011 Share Posted September 6, 2011 Dude, I said divide it. Milliseconds / 1000 Link to comment
NotAvailable Posted September 6, 2011 Share Posted September 6, 2011 Mhm... Use tonumber to get the specified amount. Then calculate it Link to comment
megaman54 Posted September 6, 2011 Author Share Posted September 6, 2011 Ahh, i dont really understand so i must make a example.. So its like this? : function calcMsecs(player, command, mSecs) seconds = tonumber(mSecs) / 1000 outputChatBox(seconds, player) end addCommandHandler("msecs", calcMsecs) Link to comment
NotAvailable Posted September 6, 2011 Share Posted September 6, 2011 Don't ask me, i suck at Math Link to comment
JR10 Posted September 6, 2011 Share Posted September 6, 2011 function convertMSToSeconds ( MS ) local seconds = tonumber ( MS ) / 1000 return seconds end What you did is correct too. Link to comment
megaman54 Posted September 6, 2011 Author Share Posted September 6, 2011 Thanks again ! Link to comment
Cadu12 Posted September 6, 2011 Share Posted September 6, 2011 or function MsToSeconds( MS ) local seconds = tonumber ( MS ) * 1000 return seconds end setTimer( function, MsToSeconds( 50 ), 1 ) Link to comment
karlis Posted September 6, 2011 Share Posted September 6, 2011 or function MsToSeconds( MS ) local seconds = tonumber ( MS ) * 1000 return seconds end setTimer( function, MsToSeconds( 50 ), 1 ) seriusly, wtf is that? Link to comment
JR10 Posted September 6, 2011 Share Posted September 6, 2011 or function MsToSeconds( MS ) local seconds = tonumber ( MS ) * 1000 return seconds end setTimer( function, MsToSeconds( 50 ), 1 ) Wrong calculation, and setTimer arguments are wrong. Link to comment
Cadu12 Posted September 6, 2011 Share Posted September 6, 2011 MsToSeconds( 50 ) return 50000 setTimer for i dont have function name, then i can use "function" name Link to comment
JR10 Posted September 6, 2011 Share Posted September 6, 2011 Then it should be: SecondsToMS And setTimer is still wrong. should be: function SecondsToMS( Seconds ) local MS = tonumber ( Seconds ) * 1000 return MS end setTimer( function ( ) outputChatBox("test") end, SecondsToMS( 5) , 1 ) Link to comment
50p Posted September 6, 2011 Share Posted September 6, 2011 There is no need for new variable, simply return the results: function ms2sec( ms ) return ms / 1000; end function sec2ms( sec ) return sec * 1000; end This is all simple maths. Link to comment
qaisjp Posted September 6, 2011 Share Posted September 6, 2011 ^ 50p beat me to it D: Link to comment
Deltanic Posted September 6, 2011 Share Posted September 6, 2011 Why would you even use a function for something simple like this? I'm going to nominate this topic as the longest for a too simple question of 2011 Link to comment
qaisjp Posted September 6, 2011 Share Posted September 6, 2011 Why would you even use a function for something simple like this? I'm going to nominate this topic as the longest for a too simple question of 2011 I don't know.. maybe to prevent doing this: (6000/1000)+(1200/1000)+(201*1000)+ (6120/1000)+(1234/1003)+(291*1000)+2 when you could do functions to avoid the brackets...but meh D: eAi - WHO GOD D: Link to comment
karlis Posted September 6, 2011 Share Posted September 6, 2011 Why would you even use a function for something simple like this? I'm going to nominate this topic as the longest for a too simple question of 2011 I don't know.. maybe to prevent doing this: (6000/1000)+(1200/1000)+(201*1000)+ (6120/1000)+(1234/1003)+(291*1000)+2 when you could do functions to avoid the brackets...but meh D: eAi - WHO GOD D: this would look as ugly as now if u would have to call the func for all of them. Link to comment
JR10 Posted September 6, 2011 Share Posted September 6, 2011 megaman54 : How to covert milliseconds to seconds?JR10 : ms / 1000. megaman54 : What function is that? JR10 : What? Just divide the milliseconds. milliseconds / 1000 megaman54 : Yes, but i need the script to calculate it. I mean, i type a command like this: /calc then it outputs that in seconds. What function should i use for this? JR10 : Dude, I said divide it. Milliseconds / 1000 Oh yeah. Link to comment
Recommended Posts