diff options
Diffstat (limited to 'lua-bindings')
-rw-r--r-- | lua-bindings/src/lib.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lua-bindings/src/lib.rs b/lua-bindings/src/lib.rs index 2cce0f5..fb56b5a 100644 --- a/lua-bindings/src/lib.rs +++ b/lua-bindings/src/lib.rs | |||
@@ -225,8 +225,15 @@ impl TryFrom<LuaValue<'_>> for Point2D { | |||
225 | fn try_from(value: LuaValue<'_>) -> Result<Self, Self::Error> { | 225 | fn try_from(value: LuaValue<'_>) -> Result<Self, Self::Error> { |
226 | match value { | 226 | match value { |
227 | LuaValue::Table(table) => { | 227 | LuaValue::Table(table) => { |
228 | let x: Float = table.get::<_, LuaValue>("x")?.try_into()?; | 228 | // TODO: not really coherent with margin, which defaults to unconstrained float |
229 | let y: Float = table.get::<_, LuaValue>("y")?.try_into()?; | 229 | let x: Float = match table.get::<_, Option<LuaValue>>("x")? { |
230 | None => Float(CoreFloat::Fixed(0.)), | ||
231 | Some(f) => f.try_into()?, | ||
232 | }; | ||
233 | let y: Float = match table.get::<_, Option<LuaValue>>("y")? { | ||
234 | None => Float(CoreFloat::Fixed(0.)), | ||
235 | Some(f) => f.try_into()?, | ||
236 | }; | ||
230 | Ok(Point2D(CorePoint2D::new(x.0, y.0))) | 237 | Ok(Point2D(CorePoint2D::new(x.0, y.0))) |
231 | } | 238 | } |
232 | // Create a new float from the borrow, since it might already be borrowed, with for ex. | 239 | // Create a new float from the borrow, since it might already be borrowed, with for ex. |