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:
parent
f1b9461eb2
commit
b2f14dffee
2 changed files with 19 additions and 1 deletions
1
USAGE.md
1
USAGE.md
|
@ -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.
|
* `!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.
|
* `!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.
|
* `!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
|
### GM commands
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
inventory::Storage,
|
inventory::{Item, Storage},
|
||||||
ipc::zone::{ChatMessage, GameMasterRank},
|
ipc::zone::{ChatMessage, GameMasterRank},
|
||||||
world::ToServer,
|
world::ToServer,
|
||||||
};
|
};
|
||||||
|
@ -78,6 +78,23 @@ impl ChatHandler {
|
||||||
connection.send_inventory(true).await;
|
connection.send_inventory(true).await;
|
||||||
true
|
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" => {
|
"!reload" => {
|
||||||
connection.reload_scripts();
|
connection.reload_scripts();
|
||||||
connection.send_message("Scripts reloaded!").await;
|
connection.send_message("Scripts reloaded!").await;
|
||||||
|
|
Loading…
Add table
Reference in a new issue