reduce globals code

This commit is contained in:
Quaternions 2024-10-05 11:52:18 -07:00
parent 136b360590
commit ed3f9f9b30
3 changed files with 10 additions and 10 deletions

View File

@ -64,15 +64,15 @@ pub fn set_globals(lua:&mlua::Lua,globals:&mlua::Table<'_>)->Result<(),mlua::Err
//CFrame.new
cframe_table.raw_set("new",
lua.create_function(|ctx,(x,y,z):(f32,f32,f32)|
Ok(ctx.create_userdata(CFrame::point(x,y,z)))
lua.create_function(|_,(x,y,z):(f32,f32,f32)|
Ok(CFrame::point(x,y,z))
)?
)?;
//CFrame.Angles
cframe_table.raw_set("Angles",
lua.create_function(|ctx,(x,y,z):(f32,f32,f32)|
Ok(ctx.create_userdata(CFrame::angles(x,y,z)))
lua.create_function(|_,(x,y,z):(f32,f32,f32)|
Ok(CFrame::angles(x,y,z))
)?
)?;

View File

@ -19,13 +19,13 @@ pub fn set_globals(lua:&mlua::Lua,globals:&mlua::Table<'_>)->Result<(),mlua::Err
let color3_table=lua.create_table()?;
color3_table.raw_set("new",
lua.create_function(|ctx,(r,g,b):(f32,f32,f32)|
Ok(ctx.create_userdata(Color3::new(r,g,b)))
lua.create_function(|_,(r,g,b):(f32,f32,f32)|
Ok(Color3::new(r,g,b))
)?
)?;
color3_table.raw_set("fromRGB",
lua.create_function(|ctx,(r,g,b):(u8,u8,u8)|
Ok(ctx.create_userdata(Color3::new(r as f32/255.0,g as f32/255.0,b as f32/255.0)))
lua.create_function(|_,(r,g,b):(u8,u8,u8)|
Ok(Color3::new(r as f32/255.0,g as f32/255.0,b as f32/255.0))
)?
)?;

View File

@ -12,8 +12,8 @@ pub fn set_globals(lua:&mlua::Lua,globals:&mlua::Table<'_>)->Result<(),mlua::Err
//Vector3.new
vector3_table.raw_set("new",
lua.create_function(|ctx,(x,y,z):(f32,f32,f32)|
Ok(ctx.create_userdata(Vector3::new(x,y,z)))
lua.create_function(|_,(x,y,z):(f32,f32,f32)|
Ok(Vector3::new(x,y,z))
)?
)?;