From fc6a5878df2615262eb53cb1ca4ccfcf1e299dc6 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 01:45:45 +0200 Subject: Removed special character in APIDump --- MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua index 4c91ea89e..9a0e036b9 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua @@ -2,7 +2,7 @@ return { HOOK_PLAYER_USED_BLOCK = { - CalledWhen = "A player has just used a block (chest, furnace…). Notification only.", + CalledWhen = "A player has just used a block (chest, furnace...). Notification only.", DefaultFnName = "OnPlayerUsedBlock", -- also used as pagename Desc = [[ This hook is called after a {{cPlayer|player}} has right-clicked a block that can be used, such as a -- cgit v1.2.3 From 51b91befbd26b630cd2cecaec081edd03edfb5f3 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 23:11:59 +0200 Subject: Added RemoveItem() function to the player inventory. --- MCServer/Plugins/Debuggers/Debuggers.lua | 40 ++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 918204deb..95b36e854 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -60,9 +60,10 @@ function Initialize(Plugin) PM:BindCommand("/ff", "debuggers", HandleFurnaceFuel, "- Shows how long the currently held item would burn in a furnace"); PM:BindCommand("/sched", "debuggers", HandleSched, "- Schedules a simple countdown using cWorld:ScheduleTask()"); PM:BindCommand("/cs", "debuggers", HandleChunkStay, "- Tests the ChunkStay Lua integration for the specified chunk coords"); - PM:BindCommand("/compo", "debuggers", HandleCompo, "- Tests the cCompositeChat bindings") - PM:BindCommand("/sb", "debuggers", HandleSetBiome, "- Sets the biome around you to the specified one") - PM:BindCommand("/wesel", "debuggers", HandleWESel, "- Expands the current WE selection by 1 block in X/Z") + PM:BindCommand("/compo", "debuggers", HandleCompo, "- Tests the cCompositeChat bindings"); + PM:BindCommand("/sb", "debuggers", HandleSetBiome, "- Sets the biome around you to the specified one"); + PM:BindCommand("/wesel", "debuggers", HandleWESel, "- Expands the current WE selection by 1 block in X/Z"); + PM:BindCommand("/rmitem", "debuggers", HandleRMItem, "- Remove the specified item from the inventory."); Plugin:AddWebTab("Debuggers", HandleRequest_Debuggers) Plugin:AddWebTab("StressTest", HandleRequest_StressTest) @@ -533,7 +534,7 @@ function OnTakeDamage(Receiver, TDI) -- Receiver is cPawn -- TDI is TakeDamageInfo - LOG(Receiver:GetClass() .. " was dealt " .. DamageTypeToString(TDI.DamageType) .. " damage: Raw " .. TDI.RawDamage .. ", Final " .. TDI.FinalDamage .. " (" .. (TDI.RawDamage - TDI.FinalDamage) .. " covered by armor)"); + -- LOG(Receiver:GetClass() .. " was dealt " .. DamageTypeToString(TDI.DamageType) .. " damage: Raw " .. TDI.RawDamage .. ", Final " .. TDI.FinalDamage .. " (" .. (TDI.RawDamage - TDI.FinalDamage) .. " covered by armor)"); return false; end @@ -1105,6 +1106,37 @@ end +function HandleRMItem(a_Split, a_Player) + if ((#a_Split ~= 2) and (#a_Split ~= 3)) then + a_Player:SendMessage("Usage: /rmitem [Count]") + return true + end + + local Item = cItem() + if (not StringToItem(a_Split[2], Item)) then + a_Player:SendMessageFailure(a_Split[2] .. " isn't a valid item") + return true + end + + if (#a_Split == 3) then + local Count = tonumber(a_Split[3]) + if (Count == nil) then + a_Player:SendMessageFailure(a_Split[3] .. " isn't a valid number") + return true + end + + Item.m_ItemCount = Count + end + + local RemovedItems = a_Player:GetInventory():RemoveItem(Item) + a_Player:SendMessageSuccess("Removed " .. RemovedItems .. " Items!") + return true +end + + + + + function HandleRequest_Debuggers(a_Request) local FolderContents = cFile:GetFolderContents("./"); return "

The following objects have been returned by cFile:GetFolderContents():

  • " .. table.concat(FolderContents, "
  • ") .. "

"; -- cgit v1.2.3 From abe8a6bd4588892f27f779fd92beb941853c5583 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 23:48:06 +0200 Subject: APIDump: Documented RemoveItem(). --- MCServer/Plugins/APIDump/APIDesc.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 0e626c580..e65da1d16 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1155,6 +1155,7 @@ These ItemGrids are available in the API and can be manipulated by the plugins, HasItems = { Params = "{{cItem|cItem}}", Return = "bool", Notes = "Returns true if there are at least as many items of the specified type as in the parameter" }, HowManyCanFit = { Params = "{{cItem|cItem}}", Return = "number", Notes = "Returns the number of the specified items that can fit in the storage, including empty slots" }, HowManyItems = { Params = "{{cItem|cItem}}", Return = "number", Notes = "Returns the number of the specified items that are currently stored" }, + RemoveItem = { Params = "{{cItem}}", Return = "number", Notes = "Removes the specified item from the inventory, as many as possible, up to the item's m_ItemCount. Returns the number of items that were removed." }, RemoveOneEquippedItem = { Params = "", Return = "", Notes = "Removes one item from the hotbar's currently selected slot" }, SetArmorSlot = { Params = "ArmorSlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the specified armor slot contents" }, SetEquippedSlotNum = { Params = "EquippedSlotNum", Return = "", Notes = "Sets the currently selected hotbar slot number" }, @@ -1384,6 +1385,7 @@ local Item5 = cItem(E_ITEM_DIAMOND_CHESTPLATE, 1, 0, "thorns=1;unbreaking=3"); { Params = "SlotNum", Return = "bool", Notes = "Returns true if the specified slot is empty, or an invalid slot is specified" }, { Params = "X, Y", Return = "bool", Notes = "Returns true if the specified slot is empty, or an invalid slot is specified" }, }, + RemoveItem = { Params = "{{cItem}}", Return = "number", Notes = "Removes the specified item from the grid, as many as possible, up to the item's m_ItemCount. Returns the number of items that were removed." }, RemoveOneItem = { { Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Removes one item from the stack in the specified slot and returns it as a single cItem. Empty slots are skipped and an empty item is returned" }, -- cgit v1.2.3 From 0346ab15adaf73e4d7c4ee4cfb175d40e721adfe Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 23:51:15 +0200 Subject: Debuggers: Optimized and commented the /rmitem handler. --- MCServer/Plugins/Debuggers/Debuggers.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 95b36e854..b402c1867 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -1107,18 +1107,21 @@ end function HandleRMItem(a_Split, a_Player) - if ((#a_Split ~= 2) and (#a_Split ~= 3)) then + -- Check params: + if (a_Split[2] == nil) then a_Player:SendMessage("Usage: /rmitem [Count]") return true end + -- Parse the item type: local Item = cItem() if (not StringToItem(a_Split[2], Item)) then a_Player:SendMessageFailure(a_Split[2] .. " isn't a valid item") return true end - if (#a_Split == 3) then + -- Parse the optional item count + if (a_Split[3] ~= nil) then local Count = tonumber(a_Split[3]) if (Count == nil) then a_Player:SendMessageFailure(a_Split[3] .. " isn't a valid number") @@ -1128,8 +1131,9 @@ function HandleRMItem(a_Split, a_Player) Item.m_ItemCount = Count end - local RemovedItems = a_Player:GetInventory():RemoveItem(Item) - a_Player:SendMessageSuccess("Removed " .. RemovedItems .. " Items!") + -- Remove the item: + local NumRemovedItems = a_Player:GetInventory():RemoveItem(Item) + a_Player:SendMessageSuccess("Removed " .. NumRemovedItems .. " Items!") return true end -- cgit v1.2.3