From 3872e813f32398d55d8a038b450fc2faba3b46b6 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 26 Nov 2016 17:52:33 +0100 Subject: Debuggers: Added commands to investigate item's Lore. --- Server/Plugins/Debuggers/Debuggers.lua | 48 ++++++++++++++++++++++++++++++++++ Server/Plugins/Debuggers/Info.lua | 12 +++++++++ 2 files changed, 60 insertions(+) (limited to 'Server') diff --git a/Server/Plugins/Debuggers/Debuggers.lua b/Server/Plugins/Debuggers/Debuggers.lua index 6397962d9..27440027e 100644 --- a/Server/Plugins/Debuggers/Debuggers.lua +++ b/Server/Plugins/Debuggers/Debuggers.lua @@ -987,6 +987,28 @@ end; +function HandleGetLoreCmd(a_Split, a_Player) + local item = a_Player:GetInventory():GetEquippedItem() + if (not(item.m_Lore) or (item.m_Lore == "")) then + a_Player:SendMessage("The lore is empty") + return true + end + local dispLore = string.gsub(item.m_Lore, ".", + function(a_Char) + if (a_Char < " ") then + return string.byte(a_Char) + end + return a_Char + end + ) + a_Player:SendMessage(string.format("The lore is %d bytes: %s", string.len(item.m_Lore), dispLore)) + return true +end + + + + + function HandleHungerCmd(a_Split, a_Player) a_Player:SendMessage("FoodLevel: " .. a_Player:GetFoodLevel()); a_Player:SendMessage("FoodSaturationLevel: " .. a_Player:GetFoodSaturationLevel()); @@ -1040,6 +1062,32 @@ end +function HandleSetLoreCmd(a_Split, a_Player, a_EntireCmd) + if not(a_Split[2]) then + a_Player:SendMessageFatal("Missing an argument: the lore to set"); + return true + end + local loreToSet = a_EntireCmd:match("/setlore%s(.*)") + if not(loreToSet) then + a_Player:SendMessageFatal("Failed to extract the lore to set") + return true + end + loreToSet = loreToSet:gsub("\\([0-9][0-9][0-9])", string.char) + + local inv = a_Player:GetInventory() + local slotNum = inv:GetEquippedSlotNum() + local item = cItem(inv:GetEquippedItem()) -- Make a copy of the item + local oldLore = item.m_Lore + item.m_Lore = loreToSet + inv:SetHotbarSlot(slotNum, item) + a_Player:SendMessage("Lore set to " .. loreToSet) + return true +end + + + + + function HandleSpideyCmd(a_Split, a_Player) -- Place a line of cobwebs from the player's eyes until non-air block, in the line-of-sight of the player local World = a_Player:GetWorld(); diff --git a/Server/Plugins/Debuggers/Info.lua b/Server/Plugins/Debuggers/Info.lua index 6964a9036..06fabad14 100644 --- a/Server/Plugins/Debuggers/Info.lua +++ b/Server/Plugins/Debuggers/Info.lua @@ -100,6 +100,12 @@ g_PluginInfo = Handler = HandleGCCmd, HelpString = "Activates the Lua garbage collector" }, + ["/getlore"] = + { + Permission = "debuggers", + Handler = HandleGetLoreCmd, + HelpString = "Displays the Lore of currently held item", + }, ["/hunger"] = { Permission = "debuggers", @@ -166,6 +172,12 @@ g_PluginInfo = Handler = HandleSched, HelpString = "Schedules a simple countdown using cWorld:ScheduleTask()" }, + ["/setlore"] = + { + Permission = "debuggers", + Handler = HandleSetLoreCmd, + HelpString = "Sets the lore for the item currently in hand", + }, ["/spidey"] = { Permission = "debuggers", -- cgit v1.2.3