findWindow and class weirdness
Posted: Sun Apr 01, 2012 2:54 pm
I was making a class to wrap the window related functions:
Then I call like this:
And I get an error:
Code: Select all
CWindow = class(
function(self, windowTitle)
self.win = nil;
print(self);
print(windowTitle);
self.title = windowTitle;
print(self.title);
end
);
function CWindow:getWin()
print(self);
print(self.win);
print(self.title);
if(self.win == nil) then
self.win = findWindow(self.title);
end
if (self.win == 0) then
cprintf_ex("|red|ERROR:|white| Unable to find the |yellow|%s|white| window.\n", self.title);
cprintf_ex("|white|Launch the game and press |yellow|%s|white| restart the macro.\n", getKeyName(getStartKey()));
cprintf_ex("|red|Macro paused.\n");
stopPE();
-- getWin();
end
return self.win;
end
function CWindow:showWindow(state)
print("showWindow");
showWindow(CWindow:getWin(), state);
end
Code: Select all
window2 = CWindow("SomeProgram");
print(window2);
window2:showWindow(sw.show);
For some reason, when I call window:showWindow() I'm getting a new instance of CWindow that is empty, see "<--" abovetable: 009A7F80
SomeProgram
SomeProgram
table: 009A7F80
showWindow
table: 02395AB8 <--
nil
nil
9:45pm - .../micromacro/scripts/window.lua:16: bad argument #1 to 'findWindow' (string expected, got nil)