fix: flip direction table values

This commit is contained in:
2025-02-25 18:10:06 -05:00
parent 2b9bf1987b
commit e081813ba4
2 changed files with 7 additions and 7 deletions

View File

@@ -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<Value> {
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<Self> {
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 {