From 33c65a2afccb8031e5c929498cdbdb6c83bb645e Mon Sep 17 00:00:00 2001 From: cracyc Date: Fri, 2 Jun 2017 17:59:55 -0500 Subject: plugins/cheat: add hotkey support [Carl] --- plugins/cheat/cheat_xml.lua | 251 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100644 plugins/cheat/cheat_xml.lua (limited to 'plugins/cheat/cheat_xml.lua') diff --git a/plugins/cheat/cheat_xml.lua b/plugins/cheat/cheat_xml.lua new file mode 100644 index 00000000000..a14aee034cb --- /dev/null +++ b/plugins/cheat/cheat_xml.lua @@ -0,0 +1,251 @@ +local xml = {} + +function xml.filename(name) + return name .. ".xml" +end + +-- basic xml parser for mamecheat only +local function xml_parse(data) + local function fix_gt(str) + str = str:gsub(">=", " ge ") + str = str:gsub(">", " gt ") + return str + end + data = data:gsub("(condition=%b\"\")", fix_gt) + local cheat_str = data:match("(.*)") + + local function get_tags(str) + local arr = {} + while str ~= "" do + local tag, attr, stop + tag, attr, stop, str = str:match("<([%w!%-]+) ?(.-)(/?)[ %-]->(.*)") + + if not tag then + return arr + end + if tag:sub(0, 3) ~= "!--" then + local block = {} + if stop ~= "/" then + local nest + nest, str = str:match("(.-)(.*)") + local children = get_tags(nest) + if not next(children) then + nest = nest:gsub("