Fandom

CraftStudio Wiki

Scripting Reference/Math

< Scripting Reference

56pages on
this wiki
Add New Page
Comments0 Share

math.floor, math.ceil, math.roundEdit

[number] math.floor( [number] value )
[number] math.ceil( [number] value )
[number] math.round( [number] value )

Returns the specified number respectively rounded down, rounded up or rounded to the nearest integer.

math.clampEdit

[number] math.clamp( [number] value, [number] min, [number] max )

Make sure that value is between min and max. If value is inferior than min or superior than max, it is brought back to the closest boundary.

math.randomrangeEdit

[number] math.randomrange( [number] lower, [number] upper )

Generate a random real number (a float) between lower and upper.

(Until CraftStudio Beta is released) you need to initialize the random number generator by placing the following line anywhere in your code before using math.randomrange() or math.random().

math.randomseed( os.time() )

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.