refactor: rename a few things

This commit is contained in:
2025-02-17 11:53:24 -05:00
parent 93348835ac
commit 2373d6500e
21 changed files with 7 additions and 7 deletions

33
src/lua/direction.rs Normal file
View File

@@ -0,0 +1,33 @@
use mlua::{FromLua, IntoLua, Lua, Result, Value};
#[derive(Clone)]
pub struct Direction {
pub x: f32,
pub y: f32,
}
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)?;
Ok(Value::Table(table))
}
}
impl FromLua for Direction {
fn from_lua(value: Value, _lua: &Lua) -> Result<Self> {
if let Value::Table(table) = value {
Ok(Self {
x: table.get("x")?,
y: table.get("y")?,
})
} else {
Err(mlua::Error::FromLuaConversionError {
from: value.type_name(),
to: "Direction".to_string(),
message: None,
})
}
}
}