Skip to content

Commit

Permalink
Fix reload XML files from lua (#4844)
Browse files Browse the repository at this point in the history
* Fix reload XML files from lua

* Fix error message
  • Loading branch information
ramon-bernardo authored Nov 24, 2024
1 parent bc60e5e commit 2aab267
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
-- If you don't intend to use quests.xml, you can delete this file.
local xmlQuest = GlobalEvent("Load XML Quests")

function xmlQuest.onStartup()
local questDoc = XMLDocument("data/XML/quests.xml")
if not questDoc then
io.write(
"[Warning - GlobalEvent::onStartup] Could not load quests.xml.\n")
local function loadXMLQuests()
local doc = XMLDocument("data/XML/quests.xml")
if not doc then
io.write("[Warning - Scripts::XML::loadXMLQuests] Could not load quests.xml.\n")
return true
end

local quests = questDoc:child("quests")
local quests = doc:child("quests")
for questNode in quests:children() do
local missions = {}
for missionNode in questNode:children() do
Expand Down Expand Up @@ -41,7 +39,6 @@ function xmlQuest.onStartup()
missions = missions
}):register()
end
return true
end

xmlQuest:register()
loadXMLQuests()
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,17 @@ local function configureRaidEvent(node)
return raid
end

local event = GlobalEvent("load raids.xml")

function event.onStartup()
local function loadXMLRaids()
local doc = XMLDocument("data/raids/raids.xml")
if not doc then
return true
io.write("[Warning - Scripts::XML::loadXMLRaids] Could not load raids.xml.\n")
return
end

local raids = doc:child("raids")

io.write(">> Loading legacy XML raids from data/raids/raids.xml...\n")

local loaded, start = 0, os.mtime()
for node in raids:children() do
local enabled = node:attribute("enabled")
Expand All @@ -238,7 +238,8 @@ function event.onStartup()
end
end
end

io.write(">> Loaded " .. loaded .. " raids in " .. os.mtime() - start .. "ms.\n")
end

event:register()
loadXMLRaids()
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,17 @@ local function configureActionEvent(node)
return action
end

local event = GlobalEvent("load actions.xml")

function event.onStartup()
local function loadXMLActions()
local doc = XMLDocument("data/actions/actions.xml")
if not doc then
io.write("[Warning - GlobalEvent::onStartup] Could not load data/actions/actions.xml.\n")
return true
io.write("[Warning - Scripts::XML::loadXMLActions] Could not load actions.xml.\n")
return
end

local actions = doc:child("actions")

io.write(">> Loading legacy XML actions from data/actions/actions.xml...\n")

local loaded, start = 0, os.mtime()
for node in actions:children() do
local action = configureActionEvent(node)
Expand All @@ -112,7 +111,8 @@ function event.onStartup()
loaded = loaded + 1
end
end

io.write(">> Loaded " .. loaded .. " actions in " .. os.mtime() - start .. "ms.\n")
end

event:register()
loadXMLActions()

0 comments on commit 2aab267

Please sign in to comment.