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

Add the !item debug command to give items by name

Compared to the //gm item command which only accepts IDs.

Fixes #50
This commit is contained in:
Joshua Goins 2025-06-28 11:22:21 -04:00
parent f1b9461eb2
commit b2f14dffee
2 changed files with 19 additions and 1 deletions

View file

@ -114,6 +114,7 @@ These special debug commands start with `!` and are custom to Kawari.
* `!festival <id1> <id2> <id3> <id4>`: Sets the festival in the current zone. Multiple festivals can be set together to create interesting effects.
* `!reload`: Reloads `Global.lua` that is normally only loaded once at start-up.
* `!finishevent`: Forcefully finishes the current event, useful if the script has an error and you're stuck talking to something.
* `!item <name>`: Gives you an item matching by name.
### GM commands

View file

@ -1,5 +1,5 @@
use crate::{
inventory::Storage,
inventory::{Item, Storage},
ipc::zone::{ChatMessage, GameMasterRank},
world::ToServer,
};
@ -78,6 +78,23 @@ impl ChatHandler {
connection.send_inventory(true).await;
true
}
"!item" => {
let (_, name) = chat_message.message.split_once(' ').unwrap();
{
let mut gamedata = connection.gamedata.lock().unwrap();
if let Some((_, id)) = gamedata.get_item_by_name(name) {
connection
.player_data
.inventory
.add_in_next_free_slot(Item { quantity: 1, id });
}
}
connection.send_inventory(false).await;
true
}
"!reload" => {
connection.reload_scripts();
connection.send_message("Scripts reloaded!").await;