1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-04-20 14:47:45 +00:00

Return nil when pop range isn't found

This commit is contained in:
Joshua Goins 2025-03-29 08:34:55 -04:00
parent 227c8c1eb2
commit 0d95f0d5b8

View file

@ -147,17 +147,16 @@ impl UserData for Zone {
fn add_methods<M: UserDataMethods<Self>>(methods: &mut M) { fn add_methods<M: UserDataMethods<Self>>(methods: &mut M) {
methods.add_method( methods.add_method(
"get_pop_range", "get_pop_range",
|_, this, id: u32| -> mlua::Result<Position> { |lua: &Lua, this, id: u32| -> mlua::Result<mlua::Value> {
if let Some(pop_range) = this.find_pop_range(id) { if let Some(pop_range) = this.find_pop_range(id) {
let trans = pop_range.0.transform.translation; let trans = pop_range.0.transform.translation;
return Ok(Position { return lua.pack(Position {
x: trans[0], x: trans[0],
y: trans[1], y: trans[1],
z: trans[2], z: trans[2],
}); });
} }
// FIXME: return nil? Ok(mlua::Nil)
Ok(Position::default())
}, },
); );
} }