Hello Guest it is March 28, 2024, 05:30:29 AM

Author Topic: Signal Script - struggling to get it working  (Read 1308 times)

0 Members and 1 Guest are viewing this topic.

Signal Script - struggling to get it working
« on: March 04, 2018, 08:33:13 AM »
Hi all,
I just started to get my head arround the LUA stuff and trying to get a simple singnal scirpt working.

As a simple starting point I wanted to use my Probe to actually trigger the status of an general output.
I have added a few lines of code in my SigLib in the Screen Load script:

Code: [Select]
[mc.ISIG_PROBE] = function (state)
    inst = mc.mcGetInstance()
    local out1handle = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT1)
    local out1state = mc.mcSignalGetState(out1handle)
    if (state == 1) then     
        mc.mcSignalSetState(out1state, true)
    else
        mc.mcSignalSetState(out1state, false)
    end
end,

As far as I understand it should act on my Probe as input.
Get the handle and state for desired output and set it accordingly.

However - this doesn't actually work.

What am I doing wrong here??
Re: Signal Script - struggling to get it working
« Reply #1 on: March 04, 2018, 04:53:33 PM »
Try this (I haven't tested it):

    local out1handle = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT1)
    mc.mcSignalSetState(out1handle , state)

In C, the state is true/false, but in LUA it is 0/1.

Allan
 
« Last Edit: March 04, 2018, 05:02:05 PM by Fledermaus »
Re: Signal Script - struggling to get it working
« Reply #2 on: March 08, 2018, 02:54:03 AM »
Thanks Allan!

tose two lines are working :)