Hello Guest it is March 29, 2024, 04:45:09 AM

Author Topic: lua script - outputs, if  (Read 1142 times)

0 Members and 1 Guest are viewing this topic.

lua script - outputs, if
« on: July 23, 2018, 06:07:17 AM »
Hi, my program, on button


Quote
local inst = mc.mcGetInstance()
local Output16 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT16)
local Output5 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT5)
local Output12 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT12)

mc.mcSignalSetState(Output16, 1)  --On
mc.mcSignalSetState(Output5, 0)  --Off
mc.mcSignalSetState(Output12, 0)  --Off

 i want to add "if" output 24 csmio ip have 1 then, but i write it (down) and doesnt work, sb could help me?

Quote
if (mc.OSIG_OUTPUT24()==1)then

local inst = mc.mcGetInstance()
local Output16 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT16)
local Output5 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT5)
local Output12 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT12)

mc.mcSignalSetState(Output16, 1)  --On
mc.mcSignalSetState(Output5, 0)  --Off
mc.mcSignalSetState(Output12, 0)  --Off
end


Re: lua script - outputs, if
« Reply #1 on: July 24, 2018, 02:41:18 AM »
Hi,

Code: [Select]
if (mc.OSIG_OUTPUT24()==1)then
is  wrong. You cannot read a signal directly like that. You have to get the signal handle then read the state of the memory location
indentifed by that handle.

Code: [Select]
hsig=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT24)
local output24state=mc.mcSignalGetState(hsig)
if output24state==1  then
........
........

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'