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.new
cframe_table.raw_set("new", cframe_table.raw_set("new",
lua.create_function(|ctx,(x,y,z):(f32,f32,f32)| lua.create_function(|_,(x,y,z):(f32,f32,f32)|
Ok(ctx.create_userdata(CFrame::point(x,y,z))) Ok(CFrame::point(x,y,z))
)? )?
)?; )?;
//CFrame.Angles //CFrame.Angles
cframe_table.raw_set("Angles", cframe_table.raw_set("Angles",
lua.create_function(|ctx,(x,y,z):(f32,f32,f32)| lua.create_function(|_,(x,y,z):(f32,f32,f32)|
Ok(ctx.create_userdata(CFrame::angles(x,y,z))) 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()?; let color3_table=lua.create_table()?;
color3_table.raw_set("new", color3_table.raw_set("new",
lua.create_function(|ctx,(r,g,b):(f32,f32,f32)| lua.create_function(|_,(r,g,b):(f32,f32,f32)|
Ok(ctx.create_userdata(Color3::new(r,g,b))) Ok(Color3::new(r,g,b))
)? )?
)?; )?;
color3_table.raw_set("fromRGB", color3_table.raw_set("fromRGB",
lua.create_function(|ctx,(r,g,b):(u8,u8,u8)| lua.create_function(|_,(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))) 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.new
vector3_table.raw_set("new", vector3_table.raw_set("new",
lua.create_function(|ctx,(x,y,z):(f32,f32,f32)| lua.create_function(|_,(x,y,z):(f32,f32,f32)|
Ok(ctx.create_userdata(Vector3::new(x,y,z))) Ok(Vector3::new(x,y,z))
)? )?
)?; )?;