Qorm
|
  |
| Joined: 25 Jul 2010 |
| Total Posts: 1650 |
|
|
| 15 May 2015 07:55 PM |
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round
just make life easier |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 08:08 PM |
support. I'm too lazy to type a few lines of code for a process as simple as rounding :P
I'd like to use
math.round(1.5)
to return the number 2
|
|
|
| Report Abuse |
|
|
Qorm
|
  |
| Joined: 25 Jul 2010 |
| Total Posts: 1650 |
|
|
| 15 May 2015 10:15 PM |
| math.round() would be 100x easier and it requires 12 characters and may be more efficient |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 11:06 PM |
sure why not
the second one |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 11:09 PM |
I know an even shorter one:
math.ceil()
And the other one, which is the same length:
math.floor()
It allows you more choice over how you want numbers rounded, which can be a big deal if your game uses a lot of decimal-integer conversions. |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 11:09 PM |
just make a modulescript library, and have an argument with the number you want to round or something I don't know
can't you just put your macroed code down somewhere copy paste replace x with numbers done? |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 11:10 PM |
well yeah but
what if you want to just round to the nearest integer and not just up or down?
we would still be able to use math.ceil() and math.floor()
the second one |
|
|
| Report Abuse |
|
|
Qorm
|
  |
| Joined: 25 Jul 2010 |
| Total Posts: 1650 |
|
|
| 16 May 2015 09:31 AM |
| math.floor() goes down... math.ceil() goes up... math.round() will go either way! |
|
|
| Report Abuse |
|
|
| |
|
|
| 16 May 2015 11:24 PM |
*facepalm*
that requires editing of the lua coding language itself
if you REALLY want to do that
bother Brazil about it |
|
|
| Report Abuse |
|
|
|
| 16 May 2015 11:51 PM |
sure but why would you need to round
Save the plants! Plants > animals! |
|
|
| Report Abuse |
|
|
Qorm
|
  |
| Joined: 25 Jul 2010 |
| Total Posts: 1650 |
|
|
| 17 May 2015 10:23 AM |
| a gui that indicates someones health by % or by number text for example |
|
|
| Report Abuse |
|
|
sonihi
|
  |
| Joined: 27 Jun 2009 |
| Total Posts: 3655 |
|
|
| 17 May 2015 10:27 AM |
function round(n) if n-math.floor(n)<0.5 then return math.floor(n) end else return math.ceil(n) end
A rounding function! |
|
|
| Report Abuse |
|
|
Qorm
|
  |
| Joined: 25 Jul 2010 |
| Total Posts: 1650 |
|
| |
|
|
| 17 May 2015 12:57 PM |
" a gui that indicates someones health by % or by number text for example" *facepalm* make the gui 300 px long then subtract 3 for every 1 health gone
Save the plants! Plants > animals! |
|
|
| Report Abuse |
|
|
Qorm
|
  |
| Joined: 25 Jul 2010 |
| Total Posts: 1650 |
|
|
| 17 May 2015 01:29 PM |
@above WTF? *facepalm* this is what you do ok
frame=script.Parent:findFirstChild("Frame") frame.Size=UDim2.new(1,0,1,0) --100%... while true and wait() do --ok, pretend like the frame is inside another frame which indicates the health by % frame.Size.Scale=frame.Size.Scale/frame.Parent.Size.Scale*100 --this is how you get a % end
also, input should be like this if your health is, lets say 43/125: 34.4%, lets round that up using the inexistent math.round now..
frame.Size.Scale=math.round(frame.Size.Scale/frame.Parent.Size.Scale*100) and the health shall be 43/125, so since math.round is there it will automatically be rounded up to 34; 34%
your welcome for the tip and explanation |
|
|
| Report Abuse |
|
|