From c2621bbafa1ba146bde66026e95bd89463fa30d5 Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Thu, 30 Oct 2025 08:14:06 +0100 Subject: [PATCH] XML added attribute version for states --- src/plugins/xml.lua | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/plugins/xml.lua b/src/plugins/xml.lua index 8320990..8852b73 100644 --- a/src/plugins/xml.lua +++ b/src/plugins/xml.lua @@ -273,14 +273,26 @@ function BaseElement:fromXML(node, scope) if child.children then for _, stateChild in ipairs(child.children) do local propName = stateChild.tag - local value = convertValue(stateChild.value, scope) - local capitalizedName = propName:sub(1,1):upper() .. propName:sub(2) - local methodName = "set"..capitalizedName.."State" + local value - if self[methodName] then - self[methodName](self, stateName, value) + if stateChild.attributes and stateChild.attributes.value then + value = convertValue(stateChild.attributes.value, scope) + elseif stateChild.value then + value = convertValue(stateChild.value, scope) else - log.warn("XMLParser: State method '" .. methodName .. "' not found for element '" .. self:getType() .. "'") + log.warn("XMLParser: State property '" .. propName .. "' has no value") + value = nil + end + + if value ~= nil then + local capitalizedName = propName:sub(1,1):upper() .. propName:sub(2) + local methodName = "set"..capitalizedName.."State" + + if self[methodName] then + self[methodName](self, stateName, value) + else + log.warn("XMLParser: State method '" .. methodName .. "' not found for element '" .. self:getType() .. "'") + end end end end