1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-06-30 03:37:45 +00:00

Add the //gm item command back

I never actually finished the Lua version, oops.
This commit is contained in:
Joshua Goins 2025-06-28 11:18:17 -04:00
parent 99a165e405
commit f1b9461eb2
3 changed files with 25 additions and 0 deletions

View file

@ -0,0 +1,9 @@
required_rank = GM_RANK_DEBUG
command_sender = "[item] "
function onCommand(args, player)
local id = args[1]
player:add_item(id)
printf(player, "Added %s to your inventory.", id)
end

View file

@ -780,6 +780,13 @@ impl ZoneConnection {
.await;
}
}
Task::AddItem { id } => {
self.player_data.inventory.add_in_next_free_slot(Item {
id: *id,
quantity: 1,
});
self.send_inventory(false).await;
}
}
}
player.queued_tasks.clear();

View file

@ -33,6 +33,7 @@ pub enum Task {
ChangeWeather { id: u16 },
AddGil { amount: u32 },
UnlockOrchestrion { id: u16, on: bool },
AddItem { id: u32 },
}
#[derive(Default, Clone)]
@ -248,6 +249,10 @@ impl LuaPlayer {
on: unlocked == 1,
});
}
fn add_item(&mut self, id: u32) {
self.queued_tasks.push(Task::AddItem { id });
}
}
impl UserData for LuaPlayer {
@ -379,6 +384,10 @@ impl UserData for LuaPlayer {
this.unlock_orchestrion(unlock, id);
Ok(())
});
methods.add_method_mut("add_item", |_, this, id: u32| {
this.add_item(id);
Ok(())
});
}
fn add_fields<F: UserDataFields<Self>>(fields: &mut F) {