summaryrefslogtreecommitdiffstats
path: root/MCServer
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--MCServer/Plugins/ChunkWorx/chunkworx_main.lua53
-rw-r--r--MCServer/Plugins/ChunkWorx/chunkworx_web.lua61
2 files changed, 62 insertions, 52 deletions
diff --git a/MCServer/Plugins/ChunkWorx/chunkworx_main.lua b/MCServer/Plugins/ChunkWorx/chunkworx_main.lua
index ab9962387..f74c4ea2d 100644
--- a/MCServer/Plugins/ChunkWorx/chunkworx_main.lua
+++ b/MCServer/Plugins/ChunkWorx/chunkworx_main.lua
@@ -6,20 +6,27 @@ CX = 0
CZ = 0
CURRENT = 0
TOTAL = 0
+
-- AREA Variables
AreaStartX = -10
AreaStartZ = -10
AreaEndX = 10
AreaEndZ = 10
+
-- RADIAL Variables
RadialX = 0
RadialZ = 0
-Radius = 1
+Radius = 10
+
-- WORLD
WORK_WORLD = cRoot:Get():GetDefaultWorld():GetName()
WW_instance = cRoot:Get():GetDefaultWorld()
WORLDS = {}
+
+
+
+
function Initialize(Plugin)
PLUGIN = Plugin
@@ -36,39 +43,25 @@ function Initialize(Plugin)
LOG("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": NO WORLD found :(")
end
- PLUGIN.IniFile = cIniFile("ChunkWorx.ini")
- if (PLUGIN.IniFile:ReadFile() == false) then
- PLUGIN.IniFile:HeaderComment("ChunkWorx Save")
- PLUGIN.IniFile:AddKeyName("Area data")
- 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)
- PLUGIN.IniFile:AddKeyName("Radial data")
- PLUGIN.IniFile:SetValueI("Radial data", "RadialX", RadialX)
- PLUGIN.IniFile:SetValueI("Radial data", "RadialZ", RadialZ)
- PLUGIN.IniFile:SetValueI("Radial data", "Radius", Radius)
- PLUGIN.IniFile:WriteFile()
- end
-
- AreaStartX = PLUGIN.IniFile:GetValueI("Area data", "StartX")
- AreaStartZ = PLUGIN.IniFile:GetValueI("Area data", "StartZ")
- AreaEndX = PLUGIN.IniFile:GetValueI("Area data", "EndX")
- AreaEndZ = PLUGIN.IniFile:GetValueI("Area data", "EndZ")
-
- RadialX = PLUGIN.IniFile:GetValueI("Radial data", "RadialX")
- RadialZ = PLUGIN.IniFile:GetValueI("Radial data", "RadialZ")
- Radius = PLUGIN.IniFile:GetValueI("Radial data", "Radius")
+ -- Read the stored values:
+ local SettingsIni = cIniFile();
+ SettingsIni:ReadFile("ChunkWorx.ini"); -- ignore any read errors
+ AreaStartX = SettingsIni:GetValueSetI("Area data", "StartX", AreaStartX)
+ AreaStartZ = SettingsIni:GetValueSetI("Area data", "StartZ", AreaStartZ)
+ AreaEndX = SettingsIni:GetValueSetI("Area data", "EndX", AreaEndX)
+ AreaEndZ = SettingsIni:GetValueSetI("Area data", "EndZ", AreaEndZ)
+ RadialX = SettingsIni:GetValueSetI("Radial data", "RadialX", RadialX)
+ RadialZ = SettingsIni:GetValueSetI("Radial data", "RadialZ", RadialZ)
+ Radius = SettingsIni:GetValueSetI("Radial data", "Radius", Radius)
+ SettingsIni:WriteFile("ChunkWorx.ini");
LOG("Initialized " .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion())
- --LOG("Test1: " .. math.fmod(1.5, 1)) - return fractional part!
return true
end
-function OnDisable()
- PLUGIN.IniFile:WriteFile()
- LOG(PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. " is shutting down...")
-end
+
+
+
function OnTick( DeltaTime )
if (GENERATION_STATE == 1 or GENERATION_STATE == 3) then
@@ -128,7 +121,7 @@ function OnTick( DeltaTime )
end
end
end
- WW_instance:SaveAllChunks()
+ WW_instance:QueueSaveAllChunks()
WW_instance:UnloadUnusedChunks()
end
end
diff --git a/MCServer/Plugins/ChunkWorx/chunkworx_web.lua b/MCServer/Plugins/ChunkWorx/chunkworx_web.lua
index e9a930c92..44993f81c 100644
--- a/MCServer/Plugins/ChunkWorx/chunkworx_web.lua
+++ b/MCServer/Plugins/ChunkWorx/chunkworx_web.lua
@@ -1,11 +1,44 @@
+
+-- chunkworx_web.lua
+
+-- WebAdmin-related functions
+
+
+
+
+
local function Buttons_Player( Name )
return "<form method='POST'><input type='hidden' name='PlayerName' value='"..Name.."'><input type='submit' name='PlayerExact' value='Exact'><input type='submit' name='Player3x3' value='3x3'></form>"
end
+
+
+
+
local function Button_World( Name )
return "<form method='POST'><input type='hidden' name='WorldName' value='"..Name.."'><input type='submit' name='SelectWorld' value='Select'></form>"
end
+
+
+
+
+local function SaveSettings()
+ local SettingsIni = cIniFile()
+ SettingsIni:SetValueI("Area data", "StartX", AreaStartX)
+ SettingsIni:SetValueI("Area data", "StartZ", AreaStartZ)
+ SettingsIni:SetValueI("Area data", "EndX", AreaEndX)
+ SettingsIni:SetValueI("Area data", "EndZ", AreaEndZ)
+ SettingsIni:SetValueI("Radial data", "RadialX", RadialX)
+ SettingsIni:SetValueI("Radial data", "RadialZ", RadialZ)
+ SettingsIni:SetValueI("Radial data", "Radius", Radius)
+ SettingsIni:WriteFile("ChunkWorx.ini")
+end
+
+
+
+
+
function HandleRequest_Generation( Request )
local Content = ""
if (Request.PostParams["AGHRRRR"] ~= nil) then
@@ -69,21 +102,12 @@ function HandleRequest_Generation( Request )
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)
+ SaveSettings();
if (OPERATION_CODE == 0) then
GENERATION_STATE = 1
elseif (OPERATION_CODE == 1) then
GENERATION_STATE = 3
end
- PLUGIN.IniFile:WriteFile()
Content = ProcessingContent()
return Content
end
@@ -93,26 +117,19 @@ function HandleRequest_Generation( Request )
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"])
+ RadialX = tonumber(Request.PostParams["FormRadialX"]) or 0
+ RadialZ = tonumber(Request.PostParams["FormRadialZ"]) or 0
+ Radius = tonumber(Request.PostParams["FormRadius"]) or 10
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)
+ SaveSettings()
if (OPERATION_CODE == 0) then
GENERATION_STATE = 1
elseif (OPERATION_CODE == 1) then
GENERATION_STATE = 3
end
- PLUGIN.IniFile:WriteFile()
Content = ProcessingContent()
return Content
end
@@ -214,7 +231,7 @@ function HandleRequest_Generation( Request )
Content = Content .. "</form>"
-- SELECTING RADIAL
- Content = Content .. "<h4>Radial: </h4>Center X, Center Z, Raduis (0 to any)"
+ Content = Content .. "<h4>Radial: </h4>Center X, Center Z, Radius"
Content = Content .. "<form method='POST'>"
Content = Content .. "<input type='text' name='FormRadialX' value='" .. RadialX .. "'><input type='text' name='FormRadialZ' value='" .. RadialZ .. "'><input type='text' name='FormRadius' value='" .. Radius .. "'>"
Content = Content .. "<input type='submit' name='StartRadial' value='Start'>"