From e673a12beb7d79b75a0f4cc4a426d23cb136f0a2 Mon Sep 17 00:00:00 2001 From: Quaternions <krakow20@gmail.com> Date: Wed, 23 Apr 2025 13:32:16 -0700 Subject: [PATCH] roblox_emulator: support more Vector3.new argument variants --- lib/roblox_emulator/src/runner/vector3.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/roblox_emulator/src/runner/vector3.rs b/lib/roblox_emulator/src/runner/vector3.rs index feeeff5..a4016f6 100644 --- a/lib/roblox_emulator/src/runner/vector3.rs +++ b/lib/roblox_emulator/src/runner/vector3.rs @@ -16,8 +16,12 @@ pub fn set_globals(lua:&mlua::Lua,globals:&mlua::Table)->Result<(),mlua::Error>{ //Vector3.new table.raw_set("new", - lua.create_function(|_,(x,y,z):(Number,Number,Number)| - Ok(Vector3::new(x.into(),y.into(),z.into())) + lua.create_function(|_,(x,y,z):(Option<Number>,Option<Number>,Option<Number>)| + match (x,y,z){ + (Some(x),Some(y),Some(z))=>Ok(Vector3::new(x.into(),y.into(),z.into())), + (None,None,None)=>Ok(Vector3(glam::Vec3A::ZERO)), + _=>Err(mlua::Error::runtime("Unsupported arguments to Vector3.new")), + } )? )?;