scripting: update for elua and new wip support for teal

This commit is contained in:
SeanOMik 2024-02-28 21:10:52 -05:00
parent aadc8e5094
commit de4fb76f31
Signed by: SeanOMik
GPG Key ID: FEC9E2FC15235964
11 changed files with 834 additions and 53 deletions

846
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,7 @@ edition = "2021"
[dependencies]
lyra-engine = { path = "../../", version = "0.0.1", features = ["lua_scripting"] }
lyra-scripting = { path = "../../lyra-scripting", features = ["lua", "teal"] }
#lyra-ecs = { path = "../../lyra-ecs"}
anyhow = "1.0.75"
async-std = "1.12.0"

View File

@ -8,6 +8,7 @@ edition = "2021"
[features]
default = ["lua"]
lua = ["dep:elua"]
teal = ["lua", "elua/teal"]
[dependencies]
lyra-scripting-derive = { path = "lyra-scripting-derive" }

@ -1 +1 @@
Subproject commit 936ea606343dbcf5321b4b988de65daf8769ff3f
Subproject commit feb93f2b4ed7063e4fba366377b039ba4f9026ef

View File

@ -670,7 +670,7 @@ pub fn wrap_math_vec_copy(input: proc_macro::TokenStream) -> proc_macro::TokenSt
stringify!(#type_name).to_string()
}
fn build<'a>(_: &elua::State, builder: &mut elua::UserdataBuilder<'a, Self>) -> elua::Result<()> {
fn build<'a>(builder: &mut elua::UserdataBuilder<'a, Self>) {
#(#field_get_set_pairs)*
#matrix_wrapper_fields
@ -694,8 +694,6 @@ pub fn wrap_math_vec_copy(input: proc_macro::TokenStream) -> proc_macro::TokenSt
#vec_wrapper_methods
#custom_methods
Ok(())
}
}

View File

@ -174,9 +174,7 @@ impl elua::Userdata for ScriptBorrow {
"ScriptBorrow".to_string()
}
fn build<'a>(_: &elua::State, _: &mut elua::UserdataBuilder<'a, Self>) -> elua::Result<()> {
Ok(())
}
fn build<'a>(_: &mut elua::UserdataBuilder<'a, Self>) { }
}
/// Helper function used for reflecting userdata as a ScriptBorrow

View File

@ -163,7 +163,7 @@ impl elua::Userdata for ScriptDynamicBundle {
"Bundle".to_string()
}
fn build<'a>(_: &elua::State, builder: &mut elua::UserdataBuilder<'a, Self>) -> elua::Result<()> {
fn build<'a>(builder: &mut elua::UserdataBuilder<'a, Self>) {
builder
.function("new", |_, ()| Ok(ScriptDynamicBundle(DynamicBundle::new())))
.method_mut("push", |_, this, comp: elua::AnyUserdata| {
@ -175,7 +175,5 @@ impl elua::Userdata for ScriptDynamicBundle {
Ok(())
});
Ok(())
}
}

View File

@ -25,15 +25,10 @@ impl elua::Userdata for ScriptEntity {
"Entity".to_string()
}
fn build<'a>(
_: &elua::State,
builder: &mut elua::userdata::UserdataBuilder<'a, Self>,
) -> elua::Result<()> {
fn build<'a>(builder: &mut elua::userdata::UserdataBuilder<'a, Self>) {
builder.meta_method(elua::MetaMethod::ToString, |_, this, ()| {
Ok(format!("{:?}", this.0))
});
Ok(())
}
}
@ -58,10 +53,7 @@ impl elua::Userdata for ScriptWorldPtr {
"World".to_string()
}
fn build<'a>(
_: &elua::State,
builder: &mut elua::UserdataBuilder<'a, Self>,
) -> elua::Result<()> {
fn build<'a>(builder: &mut elua::UserdataBuilder<'a, Self>) {
builder
.method_mut("spawn", |_, this, vals: elua::ValueVec| {
let world = this.as_mut();
@ -312,7 +304,5 @@ impl elua::Userdata for ScriptWorldPtr {
Ok(LuaResHandle::from(handle))
});
Ok(())
}
}

View File

@ -15,7 +15,7 @@ impl elua::Userdata for LuaActionHandler {
"ActionHandler".to_string()
}
fn build<'a>(_: &elua::State, builder: &mut elua::UserdataBuilder<'a, Self>) -> elua::Result<()> {
fn build<'a>(builder: &mut elua::UserdataBuilder<'a, Self>) {
builder.function("new", |_, table: elua::Table| {
let mut handler = ActionHandler::new();
@ -146,7 +146,6 @@ impl elua::Userdata for LuaActionHandler {
Ok(ScriptBorrow::from_resource::<ActionHandler>(None))
});
Ok(())
}
}

View File

@ -20,7 +20,7 @@ impl elua::Userdata for LuaModelComponent {
"ModelComponent".to_string()
}
fn build<'a>(_: &elua::State, builder: &mut elua::UserdataBuilder<'a, Self>) -> elua::Result<()> {
fn build<'a>(builder: &mut elua::UserdataBuilder<'a, Self>) {
builder
.function("new", |_, model: Ref<LuaResHandle>| {
let res = model.0.clone();
@ -48,8 +48,6 @@ impl elua::Userdata for LuaModelComponent {
.method(FN_NAME_INTERNAL_REFLECT, |_, this, ()| {
Ok(ScriptBorrow::from_component(Some(this.0.clone())))
});
Ok(())
}
}

View File

@ -30,7 +30,7 @@ impl elua::Userdata for LuaResHandle {
"Handle".to_string()
}
fn build<'a>(_: &elua::State, builder: &mut elua::UserdataBuilder<'a, Self>) -> elua::Result<()> {
fn build<'a>(builder: &mut elua::UserdataBuilder<'a, Self>) {
builder.field_getter("path", |_, this| Ok(this.path()));
builder.field_getter("version", |_, this| Ok(this.version()));
builder.field_getter("uuid", |_, this| Ok(this.uuid().to_string()));
@ -62,8 +62,6 @@ impl elua::Userdata for LuaResHandle {
}
}
});
Ok(())
}
}