Page 1 of 1

I'm a bit confused

Posted: Wed Jan 21, 2015 9:47 am
by BlubBlab
I picked the MM2 XML project up again when I last stopped I wanted to add a compatible layer for ROMbot because I can't remeber where I stopped I wanted to runt the code how it is, to see where it ends and what I missed.

I have this code ...

Code: Select all

xml = XML()

Code: Select all

local xmlDLL = require("LuaXml");
include("Node.lua");

---local stack = {};

XML = class(
function (self)
	-- <mylabel,</mylabel
	self.stack = {};
	self.lastXML = {};
end
);

function XML:pushS(symbol)
	table.insert(self.stack, symbol)
end

function XML:popS()
	-- = stack[#stack];
	local entry = table.remove(self.stack,#self.stack);
	return entry;
end

function XML:load2(file)
	
	self:validXML(file)
	self.lastXML = xmlDLL.load(file);
	
	return self.lastXML;
end
function XML:open(file)
	--TODO: add file checks
	local xml_load = self:load2(file)
	local node = parse(xml_load)
	return node;
end
I added the waypointlist form Rombot but what I got is:

Code: Select all

Failed to run init function, err code: 7 (Runtime error)
Xml.lua:33: attempt to call method 'load2' (a nil value)
stack traceback:
        Xml.lua:33: in function 'open'
        waypointlist.lua:24: in function 'load'
        main.lua:46: in function <main.lua:10>

Some how I'm blind I don't get why MM won't find the load2 function ???

Re: I'm a bit confused

Posted: Wed Jan 21, 2015 12:23 pm
by Administrator
My guess is that 'self' isn't a proper XML object in XML:open(). Try XML:load2() instead of self:load2() for clarity.

If that doesn't help, can you show your main.lua's init function?

Re: I'm a bit confused

Posted: Wed Jan 21, 2015 1:51 pm
by BlubBlab
True it was something like that, but it seems to work now :D