A wrapper around rlua to help with embedding teal
tealr adds some traits that replace/extend those from rlua, allowing it to generate the .d.tl
files needed for teal.
It also contains some macro's to make it easier to load/execute teal scripts. Without having to compile them yourself first.
Exposing types to teal as userdata is almost the same using tealr as it is using rlua ```rust
struct Example {}
//now, implement TealData. This tells rlua what methods are available and tealr what the types are
impl TealData for Example {
//implement your methods/functions
fn addmethods<'lua, T: TealDataMethods<'lua, Self>>(methods: &mut T) {
methods.addmethod("examplemethod", |, , x: i8| Ok(x));
methods.addmethodmut("examplemethodmut", |, , x: (i8, String)| Ok(x.1));
methods.addfunction("examplefunction", |, x: Vec
```rust
let filecontents = TypeWalker::new()
.processtype::
println!("{}",file_contents) ```
rust
let code = compile_inline_teal!("local x : number = 5 return x");
rust
let compiler = embed_compiler!("v0.10.0");
let res = rlua::Lua::new().context(|ctx| {
let code = compiler("example/basic_teal_file");
let res: u8 = ctx.load(&code).set_name("embedded_compiler")?.eval()?;
Ok(res)
})?;
You can find longer ones with comments on what each call does here
Tealr can already help with 2 ways to run teal scripts. It can compile inline teal code at the same time as your rust code It can also embed the teal compiler for you, allowing you to execute external teal scripts like normal lua scripts. There is a third method I want tealr to help with. In this mode, it will compile a teal project, pack it into 1 file and embed it into the project.
Besides support for just rlua, supporting mlua is also planned.