Luau: Vector3(x,y,z)

This commit is contained in:
unittensor 2024-01-20 23:17:38 -05:00
parent bf0ed47ceb
commit 41b9aafd54

View File

@ -1,4 +1,4 @@
use mlua::{Lua as Luau, Result, Table};
use mlua::{Lua as Luau, Result, Table, Function};
use glam::Vec3;
struct StrafeluaGlobals<'a> {
@ -13,19 +13,15 @@ impl<'a> StrafeluaGlobals<'a> {
let main_table = &self.current_vm.create_table().unwrap();
main_table.clone()
}
fn vector3(&self) -> Table<'a> {
let vec3 = &self.current_vm.create_table().unwrap();
// self.current_vm.create_function(|vm, (x,y,z): (f32,f32,f32)| {
// let vec = Vec3::new(x,y,z);
// vec3.set("x", vec.x).unwrap();
// vec3.set("y", vec.y).unwrap();
// vec3.set("z", vec.z).unwrap();
// Ok(vec3)
// }).unwrap();
return vec3.clone()
fn vector3(&self) -> Function {
return self.current_vm.create_function(|vm, (x,y,z): (f32,f32,f32)| {
let glam_vec = Vec3::new(x,y,z);
let vec3 = vm.create_table().unwrap();
vec3.set("x", glam_vec.x).unwrap();
vec3.set("y", glam_vec.y).unwrap();
vec3.set("z", glam_vec.z).unwrap();
Ok(vec3)
}).unwrap();
}
}