MetricUnitSystems
The well-known MetricUnitSystems, and a builder for Roblox systems at a game's own scale.
METRIC: SI and the metric units people read, such as km, kg, L and °C. The default for every value.US_CUSTOMARY: the United States: US gallons, quarts and cups, short tons, mpg (US).IMPERIAL: Britain: imperial gallons, pints and fluid ounces, stone, mpg (UK).-
US_CUSTOMARY_AND_IMPERIAL: the units both share, which the two fall back to: miles, feet and inches, mph, pounds, BTU, horsepower, psi, °F. ROBLOX: studs against the default avatar, 28 cm each, with studs per second and Roblox mass units.
A value shows itself in the system of the unit it was made from. To show it in another, convert it or ask that system to format it:
local MINI = MetricUnitSystems.roblox({ name = "robloxMini", metersPerStud = 0.028 })
local speed = MINI:New(part.AssemblyLinearVelocity.Magnitude, "studPerSecond")
MetricUnit.format(speed) -- in the game's studs per second
MetricUnitSystems.IMPERIAL:Format(speed) -- in mph, for a player who chose imperial
MetricUnit.format(speed:ToMetric()) -- in m/s
Types
RobloxSystemConfig
interface RobloxSystemConfig {}The options for MetricUnitSystems.roblox.
Properties
METRIC
MetricUnitSystems.METRIC: MetricUnitSystemSI and the metric units people read.
US_CUSTOMARY_AND_IMPERIAL
MetricUnitSystems.US_CUSTOMARY_AND_IMPERIAL: MetricUnitSystemThe units the United States and Britain share, which MetricUnitSystems.US_CUSTOMARY and MetricUnitSystems.IMPERIAL fall back to before metric.
US_CUSTOMARY
MetricUnitSystems.US_CUSTOMARY: MetricUnitSystemUnited States customary units.
IMPERIAL
MetricUnitSystems.IMPERIAL: MetricUnitSystemBritish imperial units.
ROBLOX
MetricUnitSystems.ROBLOX: MetricUnitSystemStuds against the default Roblox avatar, 28 cm each.
Functions
roblox
A Roblox system at a stud of metersPerStud: stud, studPerSecond, studPerSecondSquared and
robloxMassUnit at that scale, shown for lengths, speeds, accelerations and masses, and fallback (metric by
default) for everything else.
local GIANT = MetricUnitSystems.roblox({ name = "robloxGiant", metersPerStud = 2.8 })
GIANT:New(10, "stud"):In("meter") -- 28
getSystemOfUnit
The system that declares unit: a game's own system for its units, a well-known one such as IMPERIAL for
imperialPint, or nil for units every system shares, such as the second.