391
Mach4 General Discussion / Re: Multiple inputs in LUA script
« on: October 12, 2016, 12:22:09 PM »Quote
Where are you defining the inst = mc.mcGetInstance(); before getting the hSig's?
OOOppps - I tested the code in my personal editor and forgot the instance is declared automatically so I dont get errors..
try something on these lines
Code: [Select]
--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
local inst = mc.mcGetInstance()
hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT18)
Input18 = mc.mcSignalGetState(hSig) --Get state of input 18
hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT19)
Input19 = mc.mcSignalGetState(hSig) --Get state of input 19
hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT20)
Input20 = mc.mcSignalGetState(hSig) --Get state of input 20
if ((Input18 == 0) and (Input19 == 1) and (Input20 == 0)) then
mc.mcCntlSetRRO(inst, 100.0) --Set RRO to 100%
elseif ((Input18 == 1) and (Input19 == 0) and (Input20 == 1)) then
mc.mcCntlSetRRO(inst, 50.0) --Set RRO to 50%
elseif ((Input18 == 0) and (Input19 == 0) and (Input20 == 1)) then
mc.mcCntlSetRRO(inst, 25.0) --Set RRO to 25%
elseif ((Input18 == 1) and (Input19 == 0) and (Input20 == 0)) then
mc.mcCntlSetRRO(inst, 0.0) --Set RRO to 0%
end
If I get time later I will look at some debugging for ya.
DazTheGas