Hello Guest it is March 28, 2024, 05:27:17 PM

Author Topic: Working with LUA  (Read 2298 times)

0 Members and 1 Guest are viewing this topic.

Working with LUA
« on: March 28, 2016, 10:23:51 AM »

Hey Gang,
I have tried for the last few weeks to get things to work in LUA and it is challenging.  I can get some very basic code to work but I decided to try the pendant code under examples and each time the code hits
the third line of code in the main() program where it sets the color I get the error below.  Anyone have any idea what I might be doing incorrectly?  Thanks

Russ


function main()
    panel = mcLuaPanelParent;
    mc.mcCntlSetLastError(0, 'panel is parent!!!');
    panel:SetBackgroundColour(wx.wxColour(255,255,255));

**********************

mcLua ERROR: Lua: Error while running chunk
[string "C:\Mach4Hobby\LuaExamples\Pendant Project\Mai..."]:58: attempt to index upvalue 'panel' (a nil value)
stack traceback:
   [string "C:\Mach4Hobby\LuaExamples\Pendant Project\Mai..."]:58: in function 'main'
   [string "C:\Mach4Hobby\LuaExamples\Pendant Project\Mai..."]:382: in main chunk


mcLua ERROR: Lua: Error while running chunk

Debug session finished.

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Working with LUA
« Reply #1 on: March 28, 2016, 10:38:12 AM »
You cannot access the mcLuaPanelParent from a debug session its impossible as the panel parent is the main gui, the main gui is disabled whilst in the editor.

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Working with LUA
« Reply #2 on: March 28, 2016, 10:55:00 AM »
Daz,

Thanks for responding when I put all the code shared in its own panel and just tried to run it it gave the exact same error.

Russ

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Working with LUA
« Reply #3 on: March 28, 2016, 11:43:13 AM »
Heres a snippet from one of my panels if it helps

Code: [Select]
DTG = {}
DTG.panel = nil

        DTG.panel = mcLuaPanelParent;
local window = DTG.panel:GetParent();
window:SetBackgroundColour(wx.wxColour(153,180,209));
window:Refresh();
local wsize = window:GetSize();
DTG.panel:SetSize(wsize);   
     

DazTheGas
New For 2022 - Instagram: dazthegas