ChunkWorx: Updated for the cIniFile changes.
This commit is contained in:
parent
323ebf119f
commit
de6f628d2e
@ -6,20 +6,27 @@ CX = 0
|
|||||||
CZ = 0
|
CZ = 0
|
||||||
CURRENT = 0
|
CURRENT = 0
|
||||||
TOTAL = 0
|
TOTAL = 0
|
||||||
|
|
||||||
-- AREA Variables
|
-- AREA Variables
|
||||||
AreaStartX = -10
|
AreaStartX = -10
|
||||||
AreaStartZ = -10
|
AreaStartZ = -10
|
||||||
AreaEndX = 10
|
AreaEndX = 10
|
||||||
AreaEndZ = 10
|
AreaEndZ = 10
|
||||||
|
|
||||||
-- RADIAL Variables
|
-- RADIAL Variables
|
||||||
RadialX = 0
|
RadialX = 0
|
||||||
RadialZ = 0
|
RadialZ = 0
|
||||||
Radius = 1
|
Radius = 10
|
||||||
|
|
||||||
-- WORLD
|
-- WORLD
|
||||||
WORK_WORLD = cRoot:Get():GetDefaultWorld():GetName()
|
WORK_WORLD = cRoot:Get():GetDefaultWorld():GetName()
|
||||||
WW_instance = cRoot:Get():GetDefaultWorld()
|
WW_instance = cRoot:Get():GetDefaultWorld()
|
||||||
WORLDS = {}
|
WORLDS = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Initialize(Plugin)
|
function Initialize(Plugin)
|
||||||
PLUGIN = Plugin
|
PLUGIN = Plugin
|
||||||
|
|
||||||
@ -36,39 +43,25 @@ function Initialize(Plugin)
|
|||||||
LOG("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": NO WORLD found :(")
|
LOG("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": NO WORLD found :(")
|
||||||
end
|
end
|
||||||
|
|
||||||
PLUGIN.IniFile = cIniFile("ChunkWorx.ini")
|
-- Read the stored values:
|
||||||
if (PLUGIN.IniFile:ReadFile() == false) then
|
local SettingsIni = cIniFile();
|
||||||
PLUGIN.IniFile:HeaderComment("ChunkWorx Save")
|
SettingsIni:ReadFile("ChunkWorx.ini"); -- ignore any read errors
|
||||||
PLUGIN.IniFile:AddKeyName("Area data")
|
AreaStartX = SettingsIni:GetValueSetI("Area data", "StartX", AreaStartX)
|
||||||
PLUGIN.IniFile:SetValueI("Area data", "StartX", AreaStartX)
|
AreaStartZ = SettingsIni:GetValueSetI("Area data", "StartZ", AreaStartZ)
|
||||||
PLUGIN.IniFile:SetValueI("Area data", "StartZ", AreaStartZ)
|
AreaEndX = SettingsIni:GetValueSetI("Area data", "EndX", AreaEndX)
|
||||||
PLUGIN.IniFile:SetValueI("Area data", "EndX", AreaEndX)
|
AreaEndZ = SettingsIni:GetValueSetI("Area data", "EndZ", AreaEndZ)
|
||||||
PLUGIN.IniFile:SetValueI("Area data", "EndZ", AreaEndZ)
|
RadialX = SettingsIni:GetValueSetI("Radial data", "RadialX", RadialX)
|
||||||
PLUGIN.IniFile:AddKeyName("Radial data")
|
RadialZ = SettingsIni:GetValueSetI("Radial data", "RadialZ", RadialZ)
|
||||||
PLUGIN.IniFile:SetValueI("Radial data", "RadialX", RadialX)
|
Radius = SettingsIni:GetValueSetI("Radial data", "Radius", Radius)
|
||||||
PLUGIN.IniFile:SetValueI("Radial data", "RadialZ", RadialZ)
|
SettingsIni:WriteFile("ChunkWorx.ini");
|
||||||
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")
|
|
||||||
|
|
||||||
LOG("Initialized " .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion())
|
LOG("Initialized " .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion())
|
||||||
--LOG("Test1: " .. math.fmod(1.5, 1)) - return fractional part!
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function OnDisable()
|
|
||||||
PLUGIN.IniFile:WriteFile()
|
|
||||||
LOG(PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. " is shutting down...")
|
|
||||||
end
|
|
||||||
|
|
||||||
function OnTick( DeltaTime )
|
function OnTick( DeltaTime )
|
||||||
if (GENERATION_STATE == 1 or GENERATION_STATE == 3) then
|
if (GENERATION_STATE == 1 or GENERATION_STATE == 3) then
|
||||||
@ -128,7 +121,7 @@ function OnTick( DeltaTime )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
WW_instance:SaveAllChunks()
|
WW_instance:QueueSaveAllChunks()
|
||||||
WW_instance:UnloadUnusedChunks()
|
WW_instance:UnloadUnusedChunks()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,11 +1,44 @@
|
|||||||
|
|
||||||
|
-- chunkworx_web.lua
|
||||||
|
|
||||||
|
-- WebAdmin-related functions
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function Buttons_Player( Name )
|
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>"
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function Button_World( Name )
|
local function Button_World( Name )
|
||||||
return "<form method='POST'><input type='hidden' name='WorldName' value='"..Name.."'><input type='submit' name='SelectWorld' value='Select'></form>"
|
return "<form method='POST'><input type='hidden' name='WorldName' value='"..Name.."'><input type='submit' name='SelectWorld' value='Select'></form>"
|
||||||
end
|
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 )
|
function HandleRequest_Generation( Request )
|
||||||
local Content = ""
|
local Content = ""
|
||||||
if (Request.PostParams["AGHRRRR"] ~= nil) then
|
if (Request.PostParams["AGHRRRR"] ~= nil) then
|
||||||
@ -69,21 +102,12 @@ function HandleRequest_Generation( Request )
|
|||||||
AreaStartZ = tonumber(Request.PostParams["FormAreaStartZ"])
|
AreaStartZ = tonumber(Request.PostParams["FormAreaStartZ"])
|
||||||
AreaEndX = tonumber(Request.PostParams["FormAreaEndX"])
|
AreaEndX = tonumber(Request.PostParams["FormAreaEndX"])
|
||||||
AreaEndZ = tonumber(Request.PostParams["FormAreaEndZ"])
|
AreaEndZ = tonumber(Request.PostParams["FormAreaEndZ"])
|
||||||
|
SaveSettings();
|
||||||
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
|
if (OPERATION_CODE == 0) then
|
||||||
GENERATION_STATE = 1
|
GENERATION_STATE = 1
|
||||||
elseif (OPERATION_CODE == 1) then
|
elseif (OPERATION_CODE == 1) then
|
||||||
GENERATION_STATE = 3
|
GENERATION_STATE = 3
|
||||||
end
|
end
|
||||||
PLUGIN.IniFile:WriteFile()
|
|
||||||
Content = ProcessingContent()
|
Content = ProcessingContent()
|
||||||
return Content
|
return Content
|
||||||
end
|
end
|
||||||
@ -93,26 +117,19 @@ function HandleRequest_Generation( Request )
|
|||||||
and Request.PostParams["FormRadius"] ~= nil ) then --(Re)Generation valid!
|
and Request.PostParams["FormRadius"] ~= nil ) then --(Re)Generation valid!
|
||||||
-- COMMON (Re)gen
|
-- COMMON (Re)gen
|
||||||
if( Request.PostParams["StartRadial"]) then
|
if( Request.PostParams["StartRadial"]) then
|
||||||
RadialX = tonumber(Request.PostParams["FormRadialX"])
|
RadialX = tonumber(Request.PostParams["FormRadialX"]) or 0
|
||||||
RadialZ = tonumber(Request.PostParams["FormRadialZ"])
|
RadialZ = tonumber(Request.PostParams["FormRadialZ"]) or 0
|
||||||
Radius = tonumber(Request.PostParams["FormRadius"])
|
Radius = tonumber(Request.PostParams["FormRadius"]) or 10
|
||||||
AreaStartX = RadialX - Radius
|
AreaStartX = RadialX - Radius
|
||||||
AreaStartZ = RadialZ - Radius
|
AreaStartZ = RadialZ - Radius
|
||||||
AreaEndX = RadialX + Radius
|
AreaEndX = RadialX + Radius
|
||||||
AreaEndZ = RadialZ + Radius
|
AreaEndZ = RadialZ + Radius
|
||||||
|
SaveSettings()
|
||||||
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
|
if (OPERATION_CODE == 0) then
|
||||||
GENERATION_STATE = 1
|
GENERATION_STATE = 1
|
||||||
elseif (OPERATION_CODE == 1) then
|
elseif (OPERATION_CODE == 1) then
|
||||||
GENERATION_STATE = 3
|
GENERATION_STATE = 3
|
||||||
end
|
end
|
||||||
PLUGIN.IniFile:WriteFile()
|
|
||||||
Content = ProcessingContent()
|
Content = ProcessingContent()
|
||||||
return Content
|
return Content
|
||||||
end
|
end
|
||||||
@ -214,7 +231,7 @@ function HandleRequest_Generation( Request )
|
|||||||
Content = Content .. "</form>"
|
Content = Content .. "</form>"
|
||||||
|
|
||||||
-- SELECTING RADIAL
|
-- 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 .. "<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='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'>"
|
Content = Content .. "<input type='submit' name='StartRadial' value='Start'>"
|
||||||
|
Loading…
Reference in New Issue
Block a user