prolol1337 Posted June 18, 2009 Share Posted June 18, 2009 hi, i am an lua noobie and i am trying to learn so... here's a question: i have this command you see (its made by myself) function displayPlayerCoordinates(thePlayer, command) local x,y,z = getElementPosition(thePlayer) outputChatBox("your coordinates:".. x ..",".. y ..","..z, thePlayer) end addCommandHandler("pos", displayPlayerCoordinates) but when i type the command ingame it works perfectly, but it only shows coordinates that is a big float. now my question is: how can i make my command so that is dispays the float shorter like this: your coordinates: 567.12,542.89,8457.12 instead of your coordinates: 567.1232385 ,542.898776, 8457.1296396 regards prolol1337 i hope you ca help me out Link to comment
robhol Posted June 18, 2009 Share Posted June 18, 2009 You can do something like this: function round(n,decimals) return math.floor( n*(10^decimals) + 0.5)/(10^decimals) end Link to comment
prolol1337 Posted June 18, 2009 Author Share Posted June 18, 2009 You can do something like this: function round(n,decimals) return math.floor( n*(10^decimals) + 0.5)/(10^decimals) end eh sorry i am an noobie; how to use that? Link to comment
50p Posted June 18, 2009 Share Posted June 18, 2009 Or you can do something like this: longXcoord = 1234.567890; x = tonumber( string.format( "%.f2", longXcoord ) ); Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now