Hi, I’m a beginner to Lua! Trying to get an app up and running really quickly.
I tried to make a sliding panel as in this example:
https://coronalabs.com/blog/2014/04/08/widgets-creating-a-sliding-panel/
And everything worked fine when it was all in one script. However, I put the following lines in another script called “createPanel.lua”:
local widget = require("widget") local function panelTransDone( target ) --native.showAlert( "Panel", "Complete", { "Okay" } ) if ( target.completeState ) then print( "PANEL STATE IS: "..target.completeState ) end end panel = widget.newPanel{ location = "left", onComplete = panelTransDone, width = display.contentWidth \* 0.5, height = display.contentHeight, speed = 250, inEasing = easing.outBack, outEasing = easing.outCubic } panel.background = display.newRect( 0, 0, panel.width, panel.height ) panel.background:setFillColor( 0, 0.25, 0.5 ) panel:insert( panel.background ) panel.title = display.newText( "Menu", 0, 0, native.systemFontBold, 18 ) panel.title:setFillColor( 1, 1, 1 ) panel:insert( panel.title )
And in my original script I say
local createPanel = require("scripts.createPanel")
I get no errors, but when I call panel:show() in my original script, it doesn’t work. I know the createPanel() script is being called because I get the alert from
native.showAlert( "Panel", "Complete", { "Okay" } )
so I’m a bit confused.
On a side note, does anybody know if there’s a better way to debug things? Should I just be printing things out to the console a lot?