luna
Lua convenience library for nim
Summary
| Latest Version | Unknown |
|---|---|
| License | MIT |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:24 |
Tags
Installation
nimble install luna
choosenim install luna
git clone https://github.com/smallfx/luna.nim
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| luna | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Source
| Repository | https://github.com/smallfx/luna.nim |
|---|---|
| Homepage | https://github.com/smallfx/luna.nim |
| Registry Source | nimble_official |
README
luna.nim
luna.nim is a convenience library for implementing Lua scripting in the nim language.
I created luna with game engines in mind, though it probably has potential for more applications.
If you think something could be done better, please contribute! Even simple suggestions are welcome.
example
# example.nim
import lua
import luna
const lua_code = """
function example_lua_function()
return { hi = "hello" }
end
"""
# set up Lua state like normal
let L = newstate()
openlibs(L)
dostring(L, lua_code)
# call a function from our Lua instance and store the value
let lua_value: LuaVal = callLuaFunc(L, "example_lua_function")
# stringifyLuaVal is a convenient function intended for echoing LuaVal
echo stringifyLuaVal(lua_value)
The ouput of this code would then be:
$ nim -r c example.nim
...
{
"hi": "hello"
}
You can also pass an array of LuaVals to callLuaFunc. They will be used as arguments to the function.
(This can (possibly obviously) be used with LuaVals returned from callLuaFunc)
# example2.nim
import lua
import luna
const lua_code = """
function sum_values(a, b)
return a + b
end
"""
...
let lv1 = LuaVal(kind: LVNumber, n: 3)
let lv2 = LuaVal(kind: LVNumber, n: 4)
let lua_value: LuaVal = callLuaFunc(L, "sum_values", [lv1, lv2])
echo stingifyLuaVal(lua_value)
output:
$ nim -r c example2.nim
...
7