generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

using math.ceil/floor

Previous Thread :: Next Thread 
skate1011 is not online. skate1011
Joined: 13 Mar 2010
Total Posts: 688
23 May 2012 08:37 PM
What I want to do is is use math.ceil() or math.floor() with a Position or CFrame
-Skate1011
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
23 May 2012 08:49 PM
floor, ceiling

print(math.floor(0.5))
> 0

print(math.ceil(0.5))
> 1
Report Abuse
skate1011 is not online. skate1011
Joined: 13 Mar 2010
Total Posts: 688
23 May 2012 08:51 PM
No, I want to use it with a Position or a CFrame value like (1.4, 4.2, 5.2)

-Skate1011
Report Abuse
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
23 May 2012 08:52 PM
You'd have to floor each of the components of the Vector3/CFrame.


local function floor(vector)
return Vector3.new(math.floor(vector.X), math.floor(vector.Y), math.floor(vector.Z))
end

Haters gonn' hate.
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
23 May 2012 08:53 PM
If you're asking that because of your thread, then forget it.

Just do what I suggest, use the Symmetrical FormFactor. It rounds stuff automatically.
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
23 May 2012 08:54 PM
function floorCFrame(cfv)
return CFrame.new(math.floor(cfv.x),math.floor(cfv.y),math.floor(cfv.z))
end

function ceilCFrame(cfv)
return CFrame.new(math.ceil(cfv.x),math.ceil(cfv.y),math.ceil(cfv.z))
end

Part.CFrame = floorCFrame(1.5,2.5,3.5)
> 1,2,3
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
23 May 2012 08:54 PM
Hey, people, do me a favor and stop using math.floor and math.ceil everywhere for no reason.

There's a % operator. Use it.

n = n - n % 1

That'll remove the decimal part of n.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image