From e081813ba447e42df49ead0fc43ab363236ba2ce Mon Sep 17 00:00:00 2001 From: ErrorNoInternet Date: Tue, 25 Feb 2025 18:10:06 -0500 Subject: [PATCH] fix: flip direction table values --- src/lua/client/movement.rs | 2 +- src/lua/direction.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lua/client/movement.rs b/src/lua/client/movement.rs index aef4de4..8198e0e 100644 --- a/src/lua/client/movement.rs +++ b/src/lua/client/movement.rs @@ -15,7 +15,7 @@ use mlua::{FromLua, Lua, Result, Table, UserDataRef, Value}; pub fn direction(_lua: &Lua, client: &Client) -> Result { let d = client.direction(); - Ok(Direction { x: d.0, y: d.1 }) + Ok(Direction { y: d.0, x: d.1 }) } pub fn eye_position(_lua: &Lua, client: &Client) -> Result { diff --git a/src/lua/direction.rs b/src/lua/direction.rs index b677d9c..973d41c 100644 --- a/src/lua/direction.rs +++ b/src/lua/direction.rs @@ -3,15 +3,15 @@ use mlua::{FromLua, IntoLua, Lua, Result, Value}; #[derive(Clone)] pub struct Direction { - pub x: f32, pub y: f32, + pub x: f32, } impl From<&LookDirection> for Direction { fn from(d: &LookDirection) -> Self { Self { - x: d.x_rot, y: d.y_rot, + x: d.x_rot, } } } @@ -19,8 +19,8 @@ impl From<&LookDirection> for Direction { impl IntoLua for Direction { fn into_lua(self, lua: &Lua) -> Result { let table = lua.create_table()?; - table.set("x", self.x)?; table.set("y", self.y)?; + table.set("x", self.x)?; Ok(Value::Table(table)) } } @@ -28,12 +28,12 @@ impl IntoLua for Direction { impl FromLua for Direction { fn from_lua(value: Value, _lua: &Lua) -> Result { if let Value::Table(table) = value { - Ok(if let (Ok(x), Ok(y)) = (table.get(1), table.get(2)) { - Self { x, y } + Ok(if let (Ok(y), Ok(x)) = (table.get(1), table.get(2)) { + Self { y, x } } else { Self { - x: table.get("x")?, y: table.get("y")?, + x: table.get("x")?, } }) } else {