fix: flip direction table values
This commit is contained in:
parent
2b9bf1987b
commit
e081813ba4
@ -15,7 +15,7 @@ use mlua::{FromLua, Lua, Result, Table, UserDataRef, Value};
|
|||||||
|
|
||||||
pub fn direction(_lua: &Lua, client: &Client) -> Result<Direction> {
|
pub fn direction(_lua: &Lua, client: &Client) -> Result<Direction> {
|
||||||
let d = client.direction();
|
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<Vec3> {
|
pub fn eye_position(_lua: &Lua, client: &Client) -> Result<Vec3> {
|
||||||
|
@ -3,15 +3,15 @@ use mlua::{FromLua, IntoLua, Lua, Result, Value};
|
|||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Direction {
|
pub struct Direction {
|
||||||
pub x: f32,
|
|
||||||
pub y: f32,
|
pub y: f32,
|
||||||
|
pub x: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&LookDirection> for Direction {
|
impl From<&LookDirection> for Direction {
|
||||||
fn from(d: &LookDirection) -> Self {
|
fn from(d: &LookDirection) -> Self {
|
||||||
Self {
|
Self {
|
||||||
x: d.x_rot,
|
|
||||||
y: d.y_rot,
|
y: d.y_rot,
|
||||||
|
x: d.x_rot,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -19,8 +19,8 @@ impl From<&LookDirection> for Direction {
|
|||||||
impl IntoLua for Direction {
|
impl IntoLua for Direction {
|
||||||
fn into_lua(self, lua: &Lua) -> Result<Value> {
|
fn into_lua(self, lua: &Lua) -> Result<Value> {
|
||||||
let table = lua.create_table()?;
|
let table = lua.create_table()?;
|
||||||
table.set("x", self.x)?;
|
|
||||||
table.set("y", self.y)?;
|
table.set("y", self.y)?;
|
||||||
|
table.set("x", self.x)?;
|
||||||
Ok(Value::Table(table))
|
Ok(Value::Table(table))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -28,12 +28,12 @@ impl IntoLua for Direction {
|
|||||||
impl FromLua for Direction {
|
impl FromLua for Direction {
|
||||||
fn from_lua(value: Value, _lua: &Lua) -> Result<Self> {
|
fn from_lua(value: Value, _lua: &Lua) -> Result<Self> {
|
||||||
if let Value::Table(table) = value {
|
if let Value::Table(table) = value {
|
||||||
Ok(if let (Ok(x), Ok(y)) = (table.get(1), table.get(2)) {
|
Ok(if let (Ok(y), Ok(x)) = (table.get(1), table.get(2)) {
|
||||||
Self { x, y }
|
Self { y, x }
|
||||||
} else {
|
} else {
|
||||||
Self {
|
Self {
|
||||||
x: table.get("x")?,
|
|
||||||
y: table.get("y")?,
|
y: table.get("y")?,
|
||||||
|
x: table.get("x")?,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user