From 1142879cc8e6c585e6722d720ca0b58f619a5961 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 11 Dec 2014 21:21:41 +0100 Subject: Debuggers: Added loadchunk and preparechunk commands. preparechunk is not working yet because the required API is missing. --- MCServer/Plugins/Debuggers/Debuggers.lua | 77 ++++++++++++++++++++++++++++++++ MCServer/Plugins/Debuggers/Info.lua | 10 +++++ 2 files changed, 87 insertions(+) diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index dc1d02a74..74bfbf512 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -1619,3 +1619,80 @@ end + +function HandleConsoleLoadChunk(a_Split) + -- Check params: + local numParams = #a_Split + if (numParams ~= 3) and (numParams ~= 4) then + return true, "Usage: " .. a_Split[1] .. " []" + end + + -- Get the chunk coords: + local chunkX = tonumber(a_Split[2]) + if (chunkX == nil) then + return true, "Not a number: '" .. a_Split[2] .. "'" + end + local chunkZ = tonumber(a_Split[3]) + if (chunkZ == nil) then + return true, "Not a number: '" .. a_Split[3] .. "'" + end + + -- Get the world: + local world + if (a_Split[4] == nil) then + world = cRoot:Get():GetDefaultWorld() + else + world = cRoot:Get():GetWorld(a_Split[4]) + if (world == nil) then + return true, "There's no world named '" .. a_Split[4] .. "'." + end + end + + -- Queue a ChunkStay for the chunk, log a message when the chunk is loaded: + world:ChunkStay({{chunkX, chunkZ}}, nil, + function() + LOG("Chunk [" .. chunkX .. ", " .. chunkZ .. "] is loaded") + end + ) + return true +end + + + + + +function HandleConsolePrepareChunk(a_Split) + -- Check params: + local numParams = #a_Split + if (numParams ~= 3) and (numParams ~= 4) then + return true, "Usage: " .. a_Split[1] .. " []" + end + + -- Get the chunk coords: + local chunkX = tonumber(a_Split[2]) + if (chunkX == nil) then + return true, "Not a number: '" .. a_Split[2] .. "'" + end + local chunkZ = tonumber(a_Split[3]) + if (chunkZ == nil) then + return true, "Not a number: '" .. a_Split[3] .. "'" + end + + -- Get the world: + local world + if (a_Split[4] == nil) then + world = cRoot:Get():GetDefaultWorld() + else + world = cRoot:Get():GetWorld(a_Split[4]) + if (world == nil) then + return true, "There's no world named '" .. a_Split[4] .. "'." + end + end + + -- TODO: Queue the chunk for preparing, log a message when prepared + return true +end + + + + diff --git a/MCServer/Plugins/Debuggers/Info.lua b/MCServer/Plugins/Debuggers/Info.lua index 6e2591ffa..b96ef3de5 100644 --- a/MCServer/Plugins/Debuggers/Info.lua +++ b/MCServer/Plugins/Debuggers/Info.lua @@ -205,6 +205,16 @@ g_PluginInfo = Handler = HandleConsoleSchedule, HelpString = "Tests the world scheduling", }, + ["loadchunk"] = + { + Handler = HandleConsoleLoadChunk, + HelpString = "Loads the specified chunk into memory", + }, + ["preparechunk"] = + { + Handler = HandleConsolePrepareChunk, + HelpString = "Prepares the specified chunk completely (load / gen / light)", + } }, -- ConsoleCommands } -- g_PluginInfo -- cgit v1.2.3