From f6e16ce15082d867ed182690e3a80435cf60dc84 Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Fri, 15 Nov 2013 08:35:02 +1100 Subject: cProtocol add SendExperience() and debugging --- MCServer/Plugins/Debuggers/Debuggers.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'MCServer/Plugins/Debuggers') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 04a15a002..119e1525e 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -44,6 +44,7 @@ function Initialize(Plugin) PluginManager:BindCommand("/fs", "debuggers", HandleFoodStatsCmd, "- Turns regular foodstats message on or off"); PluginManager:BindCommand("/arr", "debuggers", HandleArrowCmd, "- Creates an arrow going away from the player"); PluginManager:BindCommand("/fb", "debuggers", HandleFireballCmd, "- Creates a ghast fireball as if shot by the player"); + PluginManager:BindCommand("/xpa", "debuggers", HandleAddExperience, "- Adds 200 experience to the player"); -- Enable the following line for BlockArea / Generator interface testing: -- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED); @@ -839,3 +840,8 @@ end +function HandleAddExperience(a_Split, a_Player) + a_Player->AddExperience(200); + + return true; +end \ No newline at end of file -- cgit v1.2.3 From 1b2e6e74736f975386879aa5eb064df5b2f88dac Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Fri, 15 Nov 2013 22:42:09 +1100 Subject: added cProtocol function to pass xp to client --- MCServer/Plugins/Debuggers/Debuggers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins/Debuggers') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 119e1525e..cd7da359b 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -841,7 +841,7 @@ end function HandleAddExperience(a_Split, a_Player) - a_Player->AddExperience(200); + a_Player:AddExperience(200); return true; end \ No newline at end of file -- cgit v1.2.3 From 04dff4882a3d75f3a0d432fb3377cc3f59fdf251 Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Sat, 16 Nov 2013 02:23:50 +1100 Subject: finished #143 I believe --- MCServer/Plugins/Debuggers/Debuggers.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'MCServer/Plugins/Debuggers') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 7b1217b95..badce8508 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -46,6 +46,7 @@ function Initialize(Plugin) PluginManager:BindCommand("/arr", "debuggers", HandleArrowCmd, "- Creates an arrow going away from the player"); PluginManager:BindCommand("/fb", "debuggers", HandleFireballCmd, "- Creates a ghast fireball as if shot by the player"); PluginManager:BindCommand("/xpa", "debuggers", HandleAddExperience, "- Adds 200 experience to the player"); + PluginManager:BindCommand("/xpr", "debuggers", HandleRemoveXp, "- Remove all xp"); -- Enable the following line for BlockArea / Generator interface testing: -- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED); @@ -852,3 +853,13 @@ function HandleAddExperience(a_Split, a_Player) return true; end + + + + + +function HandleRemoveXp(a_Split, a_Player) + a_Player:SetExperience(0); + + return true; +end -- cgit v1.2.3 From b72ced31649f8a851ffe60778e8a603bda941dc9 Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Sat, 16 Nov 2013 22:00:45 +1100 Subject: removed SpendExperience and changed AddExperience to handle removing Xp --- MCServer/Plugins/Debuggers/Debuggers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins/Debuggers') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index badce8508..69e724b30 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -849,7 +849,7 @@ end function HandleAddExperience(a_Split, a_Player) - a_Player:AddExperience(200); + a_Player:DelatExperience(200); return true; end -- cgit v1.2.3 From 25ccc33252b1c105c6c13ae23200b5aa49b7ed39 Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Sat, 16 Nov 2013 22:05:34 +1100 Subject: updated plugin --- MCServer/Plugins/Debuggers/Debuggers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins/Debuggers') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 69e724b30..491d294e2 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -849,7 +849,7 @@ end function HandleAddExperience(a_Split, a_Player) - a_Player:DelatExperience(200); + a_Player:DeltaExperience(200); return true; end -- cgit v1.2.3 From b3bb34974fddfae6cea9ca59d71f95e32621793d Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Sat, 16 Nov 2013 22:17:46 +1100 Subject: updated plugin again... --- MCServer/Plugins/Debuggers/Debuggers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins/Debuggers') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 491d294e2..9350606cc 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -859,7 +859,7 @@ end function HandleRemoveXp(a_Split, a_Player) - a_Player:SetExperience(0); + a_Player:SetCurrentExperience(0); return true; end -- cgit v1.2.3 From fed37bca4d12579741be97e7994f1d4b8df4bbfd Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 20 Nov 2013 21:54:37 +0100 Subject: Debuggers: Test harness for cWorld:ForEachBlockEntityInChunk(). The fill command will fill all empty slots in block entities with containment with gold nuggets, one per slot. --- MCServer/Plugins/Debuggers/Debuggers.lua | 78 ++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 19 deletions(-) (limited to 'MCServer/Plugins/Debuggers') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 9350606cc..c4811b91a 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -28,25 +28,26 @@ function Initialize(Plugin) cPluginManager.AddHook(cPluginManager.HOOK_WORLD_TICK, OnWorldTick); cPluginManager.AddHook(cPluginManager.HOOK_CHUNK_GENERATED, OnChunkGenerated); - PluginManager = cRoot:Get():GetPluginManager(); - PluginManager:BindCommand("/le", "debuggers", HandleListEntitiesCmd, "- Shows a list of all the loaded entities"); - PluginManager:BindCommand("/ke", "debuggers", HandleKillEntitiesCmd, "- Kills all the loaded entities"); - PluginManager:BindCommand("/wool", "debuggers", HandleWoolCmd, "- Sets all your armor to blue wool"); - PluginManager:BindCommand("/testwnd", "debuggers", HandleTestWndCmd, "- Opens up a window using plugin API"); - PluginManager:BindCommand("/gc", "debuggers", HandleGCCmd, "- Activates the Lua garbage collector"); - PluginManager:BindCommand("/fast", "debuggers", HandleFastCmd, "- Switches between fast and normal movement speed"); - PluginManager:BindCommand("/dash", "debuggers", HandleDashCmd, "- Switches between fast and normal sprinting speed"); - PluginManager:BindCommand("/hunger", "debuggers", HandleHungerCmd, "- Lists the current hunger-related variables"); - PluginManager:BindCommand("/poison", "debuggers", HandlePoisonCmd, "- Sets food-poisoning for 15 seconds"); - PluginManager:BindCommand("/starve", "debuggers", HandleStarveCmd, "- Sets the food level to zero"); - PluginManager:BindCommand("/fl", "debuggers", HandleFoodLevelCmd, "- Sets the food level to the given value"); - PluginManager:BindCommand("/spidey", "debuggers", HandleSpideyCmd, "- Shoots a line of web blocks until it hits non-air"); - PluginManager:BindCommand("/ench", "debuggers", HandleEnchCmd, "- Provides an instant dummy enchantment window"); - PluginManager:BindCommand("/fs", "debuggers", HandleFoodStatsCmd, "- Turns regular foodstats message on or off"); - PluginManager:BindCommand("/arr", "debuggers", HandleArrowCmd, "- Creates an arrow going away from the player"); - PluginManager:BindCommand("/fb", "debuggers", HandleFireballCmd, "- Creates a ghast fireball as if shot by the player"); - PluginManager:BindCommand("/xpa", "debuggers", HandleAddExperience, "- Adds 200 experience to the player"); - PluginManager:BindCommand("/xpr", "debuggers", HandleRemoveXp, "- Remove all xp"); + PM = cRoot:Get():GetPluginManager(); + PM:BindCommand("/le", "debuggers", HandleListEntitiesCmd, "- Shows a list of all the loaded entities"); + PM:BindCommand("/ke", "debuggers", HandleKillEntitiesCmd, "- Kills all the loaded entities"); + PM:BindCommand("/wool", "debuggers", HandleWoolCmd, "- Sets all your armor to blue wool"); + PM:BindCommand("/testwnd", "debuggers", HandleTestWndCmd, "- Opens up a window using plugin API"); + PM:BindCommand("/gc", "debuggers", HandleGCCmd, "- Activates the Lua garbage collector"); + PM:BindCommand("/fast", "debuggers", HandleFastCmd, "- Switches between fast and normal movement speed"); + PM:BindCommand("/dash", "debuggers", HandleDashCmd, "- Switches between fast and normal sprinting speed"); + PM:BindCommand("/hunger", "debuggers", HandleHungerCmd, "- Lists the current hunger-related variables"); + PM:BindCommand("/poison", "debuggers", HandlePoisonCmd, "- Sets food-poisoning for 15 seconds"); + PM:BindCommand("/starve", "debuggers", HandleStarveCmd, "- Sets the food level to zero"); + PM:BindCommand("/fl", "debuggers", HandleFoodLevelCmd, "- Sets the food level to the given value"); + PM:BindCommand("/spidey", "debuggers", HandleSpideyCmd, "- Shoots a line of web blocks until it hits non-air"); + PM:BindCommand("/ench", "debuggers", HandleEnchCmd, "- Provides an instant dummy enchantment window"); + PM:BindCommand("/fs", "debuggers", HandleFoodStatsCmd, "- Turns regular foodstats message on or off"); + PM:BindCommand("/arr", "debuggers", HandleArrowCmd, "- Creates an arrow going away from the player"); + PM:BindCommand("/fb", "debuggers", HandleFireballCmd, "- Creates a ghast fireball as if shot by the player"); + PM:BindCommand("/xpa", "debuggers", HandleAddExperience, "- Adds 200 experience to the player"); + PM:BindCommand("/xpr", "debuggers", HandleRemoveXp, "- Remove all xp"); + PM:BindCommand("/fill", "debuggers", HandleFill, "- Fills all block entities in current chunk with junk"); -- Enable the following line for BlockArea / Generator interface testing: -- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED); @@ -863,3 +864,42 @@ function HandleRemoveXp(a_Split, a_Player) return true; end + + + + + +function HandleFill(a_Split, a_Player) + local World = a_Player:GetWorld(); + local ChunkX = a_Player:GetChunkX(); + local ChunkZ = a_Player:GetChunkZ(); + World:ForEachBlockEntityInChunk(ChunkX, ChunkZ, + function(a_BlockEntity) + local BlockType = a_BlockEntity:GetBlockType(); + if ( + (BlockType == E_BLOCK_CHEST) or + (BlockType == E_BLOCK_DISPENSER) or + (BlockType == E_BLOCK_DROPPER) or + (BlockType == E_BLOCK_FURNACE) or + (BlockType == E_BLOCK_HOPPER) + ) then + -- This block entity has items (inherits from cBlockEntityWithItems), fill it: + -- Note that we're not touching lit furnaces, don't wanna mess them up + local EntityWithItems = tolua.cast(a_BlockEntity, "cBlockEntityWithItems"); + local ItemGrid = EntityWithItems:GetContents(); + local NumSlots = ItemGrid:GetNumSlots(); + local ItemToSet = cItem(E_ITEM_GOLD_NUGGET); + for i = 0, NumSlots - 1 do + if (ItemGrid:GetSlot(i):IsEmpty()) then + ItemGrid:SetSlot(i, ItemToSet); + end + end + end + end + ); + return true; +end + + + + -- cgit v1.2.3 From 07a1de8ebb58f61f2cd37db0e3382f0df9a784f0 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 22 Nov 2013 12:26:39 +0100 Subject: Debuggers: Added a test harness for cRoot:GetFurnaceRecipe(). The "/fr" command lists the furnace recipe for the currently held item. --- MCServer/Plugins/Debuggers/Debuggers.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'MCServer/Plugins/Debuggers') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index c4811b91a..e4c601da3 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -48,6 +48,7 @@ function Initialize(Plugin) PM:BindCommand("/xpa", "debuggers", HandleAddExperience, "- Adds 200 experience to the player"); PM:BindCommand("/xpr", "debuggers", HandleRemoveXp, "- Remove all xp"); PM:BindCommand("/fill", "debuggers", HandleFill, "- Fills all block entities in current chunk with junk"); + PM:BindCommand("/fr", "debuggers", HandleFurnaceRecipe, "- Shows the furnace recipe for the currently held item"); -- Enable the following line for BlockArea / Generator interface testing: -- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED); @@ -903,3 +904,23 @@ end + +function HandleFurnaceRecipe(a_Split, a_Player) + local HeldItem = a_Player:GetEquippedItem(); + local Out, NumTicks, In = cRoot.GetFurnaceRecipe(HeldItem); + if (Out ~= nil) then + a_Player:SendMessage( + "Furnace turns " .. ItemToFullString(In) .. + " to " .. ItemToFullString(Out) .. + " in " .. NumTicks .. " ticks (" .. + tostring(NumTicks / 20) .. " seconds)." + ); + else + a_Player:SendMessage("There is no furnace recipe that would smelt " .. ItemToString(HeldItem)); + end + return true; +end + + + + -- cgit v1.2.3 From 281bf8f90bbd295bb81ec09889bcaeefa689e6b2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 22 Nov 2013 16:50:03 +0100 Subject: Added cRoot:GetFurnaceFuelBurnTime() to Lua API. --- MCServer/Plugins/Debuggers/Debuggers.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins/Debuggers') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index e4c601da3..682a54676 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -49,6 +49,7 @@ function Initialize(Plugin) PM:BindCommand("/xpr", "debuggers", HandleRemoveXp, "- Remove all xp"); PM:BindCommand("/fill", "debuggers", HandleFill, "- Fills all block entities in current chunk with junk"); PM:BindCommand("/fr", "debuggers", HandleFurnaceRecipe, "- Shows the furnace recipe for the currently held item"); + PM:BindCommand("/ff", "debuggers", HandleFurnaceFuel, "- Shows how long the currently held item would burn in a furnace"); -- Enable the following line for BlockArea / Generator interface testing: -- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED); @@ -907,7 +908,7 @@ end function HandleFurnaceRecipe(a_Split, a_Player) local HeldItem = a_Player:GetEquippedItem(); - local Out, NumTicks, In = cRoot.GetFurnaceRecipe(HeldItem); + local Out, NumTicks, In = cRoot:GetFurnaceRecipe(HeldItem); if (Out ~= nil) then a_Player:SendMessage( "Furnace turns " .. ItemToFullString(In) .. @@ -924,3 +925,21 @@ end + +function HandleFurnaceFuel(a_Split, a_Player) + local HeldItem = a_Player:GetEquippedItem(); + local NumTicks = cRoot:GetFurnaceFuelBurnTime(HeldItem); + if (NumTicks > 0) then + a_Player:SendMessage( + ItemToFullString(HeldItem) .. " would power a furnace for " .. NumTicks .. + " ticks (" .. tostring(NumTicks / 20) .. " seconds)." + ); + else + a_Player:SendMessage(ItemToString(HeldItem) .. " will not power furnaces."); + end + return true; +end + + + + -- cgit v1.2.3 From 63753c5e8405837931510b8da648dc75d4970fe1 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 22 Nov 2013 20:11:24 +0100 Subject: Added cFile:GetFolderContents(). Fix 162. --- MCServer/Plugins/Debuggers/Debuggers.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'MCServer/Plugins/Debuggers') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 682a54676..c9a610f71 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -51,6 +51,8 @@ function Initialize(Plugin) PM:BindCommand("/fr", "debuggers", HandleFurnaceRecipe, "- Shows the furnace recipe for the currently held item"); PM:BindCommand("/ff", "debuggers", HandleFurnaceFuel, "- Shows how long the currently held item would burn in a furnace"); + Plugin:AddWebTab("Debuggers", HandleRequest_Debuggers); + -- Enable the following line for BlockArea / Generator interface testing: -- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED); @@ -943,3 +945,12 @@ end + +function HandleRequest_Debuggers(a_Request) + local FolderContents = cFile:GetFolderContents("./"); + return "

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

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

"; +end + + + + -- cgit v1.2.3