Hello,
I keep getting an error when typing:
Screen = class()
Then oclua returns the error:
[string "screen = class()..."]
: attempt to index global 'Screen' (a nil value)
Any tips?
This is the code:
Screen = class()
function Screen:init() end
function Screen:paint(gc) end
function Screen:timer() end
function Screen:charIn(ch) end
function Screen:arrowKey(key) end
function Screen:escapeKey() end
function Screen:enterKey() end
function Screen:tabKey() end
function Screen:contextMenu() end
function Screen:backtabKey() end
function Screen:backspaceKey() end
function Screen:clearKey() end
function Screen:mouseMove(x, y) end
function Screen:mouseDown(x, y) end
function Screen:mouseUp() end
function Screen:rightMouseDown(x, y) end
function Screen:help() end
local Screens = {}
function PushScreen(screen)
table.insert(Screens, screen)
platform.window:invalidate()
end
function PullScreen()
if #Screens > 0 then
table.remove(Screens)
platform.window:invalidate()
end
end
function activeScreen()
return Screens[#Screens] and Screens[#Screens] or Screen
end
-- Link events to ScreenManager
function on.paint(gc)
for _, screen in pairs(Screens) do
screen:paint(gc)
end
end
function on.timer()
for _, screen in pairs(Screens) do
screen:timer()
end
end
function on.charIn(ch) activeScreen():charIn(ch) end
function on.arrowKey(key) activeScreen():arrowKey(key) end
function on.escapeKey() activeScreen():escapeKey() end
function on.enterKey() activeScreen():enterKey() end
function on.tabKey() activeScreen():tabKey() end
function on.contextMenu() activeScreen():contextMenu() end
function on.backtabKey() activeScreen():backtabKey() end
function on.backspaceKey() activeScreen():backspaceKey() end
function on.clearKey() activeScreen():clearKey() end
function on.mouseDown(x, y) activeScreen():mouseDown(x, y) end
function on.mouseUp() activeScreen():mouseUp() end
function on.mouseMove(x, y) activeScreen():mouseMove(x, y) end
function on.rightMouseDown(x, y) activeScreen():rightMouseDown(x, y) end
function on.help() activeScreen():help() end
function on.create() PushScreen(Menu()) end
function on.resize() end
I tried making my own and it didn't work, so then I copied the inspired-lua code but got the same error.