luajit
Version, currently 0.1.06 versions
github.com/mdwagner/luajit.cr
LuaJIT bindings for Crystal
Nothing has been indexed for 0.1.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
luajit:
github: mdwagner/luajit.cr
version: ~> 0.1.0Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.0. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
luajit.cr
LuaJIT bindings for Crystal
Installation
-
Install LuaJIT
-
Add the dependency to your
shard.yml:
dependencies:
luajit:
github: mdwagner/luajit.cr
version: ~> 0.4.0
- Run
shards install
Usage
require "luajit"
# Basic Hello World
Luajit.run do |state|
state.execute! <<-'LUA'
print("Hello World!")
LUA
end
# Crystal type to Lua object
class Account < Luajit::LuaObject
def_class_method "new" do |state|
_self = new
Luajit.setup_userdata(state, _self, self)
1
end
def_instance_method "deposit" do |state|
_self = Luajit.userdata_value(state, self, 1)
value = state.to_i(2)
_self.deposit(value)
0
end
def_instance_method "withdraw" do |state|
_self = Luajit.userdata_value(state, self, 1)
value = state.to_i(2)
_self.withdraw(value)
0
end
def_instance_method "get_balance" do |state|
_self = Luajit.userdata_value(state, self, 1)
state.push(_self.balance)
1
end
property balance : Int32 = 0
def deposit(value : Int32)
self.balance += value
end
def withdraw(value : Int32)
self.balance -= value
end
end
Luajit.run do |state|
Luajit.create_lua_object(state, Account)
state.execute! <<-'LUA'
local account = Account.new()
account:deposit(2000)
account:withdraw(100)
assert(account:get_balance() == 1900)
LUA
end
Development
- [x] LuaJIT bindings
- [x] Works on Windows (+build script)
- [x] Safe wrappers
- [x] Better tests
- [x] Better docs + readme
- [x] Crystal to Lua object wrapper
If you encounter any bugs, feel free to open an issue!
Contributing
- Fork it (https://github.com/mdwagner/luajit.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Michael Wagner - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.0- Tagged
- Sep 2, 2025
- Commit
cef1ec3ba5c9- Indexed
- not yet
Dependents
Repository
github.com/mdwagner/luajit.cr
Metadata
- Created
- Aug 12, 2026
- Updated
- Sep 26, 2026
- Synced
- Sep 26, 2026
- Versions
- 6