Well ive run the script on my machine and the code works fine, try a bit of debug info in the the script to see what part is not working on your screen.
DazTheGas
DazTheGas,
So it ran fine and actually caused the function to operate? Wow! On my mill, it just gets ignored it seems.
Debug info huh? I've been trying to absorb some of thats stuff, but I'll admit LUA makes my mind go numb. But I've mainly been focused on what makes up a correct working script.
Where are you defining the inst = mc.mcGetInstance(); before getting the hSig's?
I've been thinking some assignment wasn't getting made, I've tried various things. But not that. I struggle to follow any logic in some of these scripts.
But I gave it a try this morning adding it between the SignalGetHandle and SignalGetState statements for each of the three inputs. It debugged fine, but had no bearing on the operation of the switch itself. Still no responce from the switch after restarting Mach.
If I take this RRO portion of the whole screen load script into a new McLUA window and do a debug on it, I get this error:
At Breakpoint line: 7 file: C:\Mach4Hobby\LuaExamples\RRO test script.mcs
mcLua ERROR: Lua: Error while running chunk
[string "C:\Mach4Hobby\LuaExamples\RRO test script.mcs..."]:7: wxLua: Expected a 'number' for parameter 1, but got a 'nil'.
Function called: 'mcSignalGetHandle(nil, number)'
01. mcSignalGetHandle(number, number, lightuserdata)
stack traceback:
[C]: in function 'mcSignalGetHandle'
[string "C:\Mach4Hobby\LuaExamples\RRO test script.mcs..."]:7: in main chunk
mcLua ERROR: Lua: Error while running chunk
Debug session finished.
That whole portion of only the RRO script I tested read as below, and yielded that noted error. But if it's in the complete Screen Load Script, I get no errors.
--Set Rapid Over Ride Value, 0%, 25%, 50% and 100%
local Input18 = 0 --Clear local Input18
local Input19 = 0 --Clear local Input19
local Input20 = 0 --Clear local Input20
local hSig = 0 --Clear local hSig
hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT18)
inst = mc.mcGetInstance()
Input18 = mc.mcSignalGetState(hSig) --Get state of input 18
hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT19)
inst = mc.mcGetInstance()
Input19 = mc.mcSignalGetState(hSig) --Get state of input 19
hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT20)
inst = mc.mcGetInstance()
Input20 = mc.mcSignalGetState(hSig) --Get state of input 20
if ((Input18 == 0) and (Input19 == 1) and (Input20 == 0)) then
local inst = mc.mcGetInstance()
mc.mcCntlSetRRO(inst, 100.0) --Set RRO to 100%
end
if ((Input18 == 1) and (Input19 == 0) and (Input20 == 1)) then
local inst = mc.mcGetInstance()
mc.mcCntlSetRRO(inst, 50.0) --Set RRO to 50%
end
if ((Input18 == 0) and (Input19 == 0) and (Input20 == 1)) then
local inst = mc.mcGetInstance()
mc.mcCntlSetRRO(inst, 25.0) --Set RRO to 25%
end
if ((Input18 == 1) and (Input19 == 0) and (Input20 == 0)) then
local inst = mc.mcGetInstance()
mc.mcCntlSetRRO(inst, 0.0) --Set RRO to 0%
end
Bob