From 66300ea7a6952c520510e2fa8d57023bbbce7a83 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Mon, 27 Aug 2012 19:06:11 +0000 Subject: Added the ChunkWorx plugin to SVN (contributed by Taugeshtu) git-svn-id: http://mc-server.googlecode.com/svn/trunk@797 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- MCServer/Plugins/ChunkWorx/chunkworx_web.lua | 210 +++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 MCServer/Plugins/ChunkWorx/chunkworx_web.lua (limited to 'MCServer/Plugins/ChunkWorx/chunkworx_web.lua') diff --git a/MCServer/Plugins/ChunkWorx/chunkworx_web.lua b/MCServer/Plugins/ChunkWorx/chunkworx_web.lua new file mode 100644 index 000000000..7bc4bc4e9 --- /dev/null +++ b/MCServer/Plugins/ChunkWorx/chunkworx_web.lua @@ -0,0 +1,210 @@ +local function Buttons_Player( Name ) + return "
" +end + +local function Button_World( Name ) + return "
" +end + +function HandleRequest_Generation( Request ) + local Content = "" + + if ( Request.PostParams["FormSetWorld"] ) then + WORK_WORLD = Request.PostParams["FormWorldName"] + WW_instance = cRoot:Get():GetWorld(WORK_WORLD) + end + + if( Request.PostParams["SelectWorld"] ~= nil + and Request.PostParams["WorldName"] ~= nil ) then -- World is selected! + WORK_WORLD = Request.PostParams["WorldName"] + WW_instance = cRoot:Get():GetWorld(WORK_WORLD) + end + + if(Request.PostParams["OperationGenerate"] ~= nil) then + OPERATION_CODE = 0 + end + if(Request.PostParams["OperationReGenerate"] ~= nil) then + OPERATION_CODE = 1 + end + + if (GENERATION_STATE == 0) then + if( Request.PostParams["FormAreaStartX"] ~= nil + and Request.PostParams["FormAreaStartZ"] ~= nil + and Request.PostParams["FormAreaEndX"] ~= nil + and Request.PostParams["FormAreaEndZ"] ~= nil ) then --(Re)Generation valid! + -- COMMON (Re)gen + if( Request.PostParams["StartArea"]) then + AreaStartX = tonumber(Request.PostParams["FormAreaStartX"]) + AreaStartZ = tonumber(Request.PostParams["FormAreaStartZ"]) + AreaEndX = tonumber(Request.PostParams["FormAreaEndX"]) + AreaEndZ = tonumber(Request.PostParams["FormAreaEndZ"]) + + PLUGIN.IniFile:DeleteValue("Area data", "StartX") + PLUGIN.IniFile:DeleteValue("Area data", "StartZ") + PLUGIN.IniFile:DeleteValue("Area data", "EndX") + PLUGIN.IniFile:DeleteValue("Area data", "EndZ") + PLUGIN.IniFile:SetValueI("Area data", "StartX", AreaStartX) + PLUGIN.IniFile:SetValueI("Area data", "StartZ", AreaStartZ) + PLUGIN.IniFile:SetValueI("Area data", "EndX", AreaEndX) + PLUGIN.IniFile:SetValueI("Area data", "EndZ", AreaEndZ) + if (OPERATION_CODE == 0) then + GENERATION_STATE = 1 + elseif (OPERATION_CODE == 1) then + GENERATION_STATE = 3 + end + PLUGIN.IniFile:WriteFile() + end + end + if( Request.PostParams["FormRadialX"] ~= nil + and Request.PostParams["FormRadialZ"] ~= nil + and Request.PostParams["FormRadius"] ~= nil ) then --(Re)Generation valid! + -- COMMON (Re)gen + if( Request.PostParams["StartRadial"]) then + RadialX = tonumber(Request.PostParams["FormRadialX"]) + RadialZ = tonumber(Request.PostParams["FormRadialZ"]) + Radius = tonumber(Request.PostParams["FormRadius"]) + AreaStartX = RadialX - Radius + AreaStartZ = RadialZ - Radius + AreaEndX = RadialX + Radius + AreaEndZ = RadialZ + Radius + + PLUGIN.IniFile:DeleteValue("Radial data", "RadialX") + PLUGIN.IniFile:DeleteValue("Radial data", "RadialZ") + PLUGIN.IniFile:DeleteValue("Radial data", "Radius") + PLUGIN.IniFile:SetValueI("Radial data", "RadialX", RadialX) + PLUGIN.IniFile:SetValueI("Radial data", "RadialZ", RadialZ) + PLUGIN.IniFile:SetValueI("Radial data", "Radius", Radius) + if (OPERATION_CODE == 0) then + GENERATION_STATE = 1 + elseif (OPERATION_CODE == 1) then + GENERATION_STATE = 3 + end + PLUGIN.IniFile:WriteFile() + end + end + -- POINT REGEN! + if( Request.PostParams["FormPointX"] ~= nil + and Request.PostParams["FormPointZ"] ~= nil ) then --ReGeneration valid! + -- EXACT + if ( Request.PostParams["PointExact"] ~= nil) then + AreaStartX = tonumber(Request.PostParams["FormPointX"]) + AreaStartZ = tonumber(Request.PostParams["FormPointZ"]) + AreaEndX = AreaStartX + AreaEndZ = AreaStartZ + GENERATION_STATE = 3 + end + -- 3x3 + if ( Request.PostParams["Point3x3"] ~= nil) then + AreaStartX = tonumber(Request.PostParams["FormPointX"]) - 1 + AreaStartZ = tonumber(Request.PostParams["FormPointZ"]) - 1 + AreaEndX = AreaStartX + 2 + AreaEndZ = AreaStartZ + 2 + GENERATION_STATE = 3 + end + end + -- PLAYERS REGEN! + if( Request.PostParams["PlayerExact"] ~= nil + and Request.PostParams["PlayerName"] ~= nil ) then -- Making BOOM! I meant, regenereate... + AreaStartX = cRoot:Get():GetWorld(WORK_WORLD):GetPlayer(Request.PostParams["PlayerName"]):GetChunkX() + AreaStartZ = cRoot:Get():GetWorld(WORK_WORLD):GetPlayer(Request.PostParams["PlayerName"]):GetChunkZ() + AreaEndX = AreaStartX + AreaEndZ = AreaStartZ + GENERATION_STATE = 3 + end + if( Request.PostParams["Player3x3"] ~= nil + and Request.PostParams["PlayerName"] ~= nil ) then -- Making BOOM! I meant, regenereate... + AreaStartX = cRoot:Get():GetWorld(WORK_WORLD):GetPlayer(Request.PostParams["PlayerName"]):GetChunkX() - 1 + AreaStartZ = cRoot:Get():GetWorld(WORK_WORLD):GetPlayer(Request.PostParams["PlayerName"]):GetChunkZ() - 1 + AreaEndX = AreaStartX + 2 + AreaEndZ = AreaStartZ + 2 + GENERATION_STATE = 3 + end + end + + --Content = Content .. "

World for operations: " .. WORK_WORLD .. "

" + --Content = Content .. "
" + --Content = Content .. "" + --Content = Content .. "
" + + -- SELECTING WORK_WORLD + Content = Content .. "

World for operations: " .. WORK_WORLD .. "

" + Content = Content .. "" + local WorldNum = 0 + local AddWorldToTable = function(World) + WorldNum = WorldNum + 1 + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + end + cRoot:Get():ForEachWorld(AddWorldToTable) + if( WorldNum == 0 ) then + Content = Content .. "" + end + Content = Content .. "
" .. WorldNum .. "." .. World:GetName() .. "" .. Button_World(World:GetName()) .. "
No worlds! O_O
" + Content = Content .. "
" + + -- SELECTING OPERATION + if (OPERATION_CODE == 0) then + Content = Content .. "

Operation: Generation

" + elseif (OPERATION_CODE == 1) then + Content = Content .. "

Operation: Regeneration

" + end + Content = Content .. "
" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "
" + + -- SELECTING AREA + Content = Content .. "

Area:

Start X, Start Z; End X, End Z" + Content = Content .. "
" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "
" + + -- SELECTING RADIAL + Content = Content .. "

Radial:

Center X, Center Z, Raduis (0 to any)" + Content = Content .. "
" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "
" + Content = Content .. "
" + Content = Content .. "
" + Content = Content .. "
" + + -- SELECTING POINT + Content = Content .. "

Point regeneration:

X, Z" + Content = Content .. "
" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "
" + + -- SELECTING PLAYERS + Content = Content .. "

Player-based regeneration:

" + Content = Content .. "" + local PlayerNum = 0 + local AddPlayerToTable = function( Player ) + PlayerNum = PlayerNum + 1 + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + end + if (cRoot:Get():GetWorld(WORK_WORLD) == nil) then + Content = Content .. "" + else + cRoot:Get():GetWorld(WORK_WORLD):ForEachPlayer( AddPlayerToTable ) + if( PlayerNum == 0 ) then + Content = Content .. "" + end + end + Content = Content .. "
" .. PlayerNum .. "." .. Player:GetName() .. "" .. Buttons_Player(Player:GetName()) .. "
Incorrect world selection
No connected players
" + Content = Content .. "
" + + + return Content +end \ No newline at end of file -- cgit v1.2.3