A simple and elegant unit conversion module for Lua
Here's how you convert from meters to feet:
local units = require( "units" )
local x = units.convert( 1 ).from( "m" ).to( "ft" )
print(x)
// 3.2808By default precision is set to 4 digits. Here is how to change it:
local units = require( "units" )
units.precision = 3
local x = units.convert( 1 ).from( "m" ).to( "ft" )
print(x)
// 3.281For now the module can convert between:
- mm
- cm
- m
- km
- ft
- in
- mi
(more to come)
A special thanks to ben-ng who did a great job with convert-units, the Javascript equivalent lib who inspired the syntax of Lua-Units.
Lua Units is a Lua module for the conversion of quantities between different unit measures. Copyright (C) 2015 David Roulin Ltd.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
For the complete terms of the GNU General Public License, please see this URL: http://www.gnu.org/licenses/gpl-2.0.html