lua
lua.cr
Bindings to liblua and a wrapper around it. UNDER CONSTRUCTION :construction:
Only Lua 5.4 or higher is supported.
Installation
Add this to your application's shard.yml
:
dependencies:
lua:
github: veelenga/lua.cr
Usage
First you need to require
Lua:
require "lua"
Then you can run a chunk of Lua code:
Lua.run %q{
local hello_message = table.concat({ 'Hello', 'from', 'Lua!' }, ' ')
print(hello_message)
} # => prints 'Hello from Lua!'
Or run a Lua file and obtain results:
p Lua.run File.new("./examples/sample.lua") # => 42.0
Or even evaluate a function and pass arguments in:
lua = Lua.load
sum = lua.run %q{
function sum(x, y)
return x + y
end
return sum
}
p sum.as(Lua::Function).call(3.2, 1) # => 4.2
lua.close
More features coming soon. Try it, that's fun :)
Contributing
- Fork it https://github.com/veelenga/lua.cr/fork
- Create a feature branch
git checkout -b my-new-feature
and implement your feature - Run tests
crystal spec
and format codecrystal tool format
- Commit your changes
git commit -am 'Add some feature'
- Push to the branch
git push origin my-new-feature
- Create a new Pull Request