PDA

View Full Version : How to make a call from SIOC to a LUA function



Roarkr
11-09-2011, 07:39 AM
Hi,

I wonder if it is possible to make a call from SIOC to a LUA function defined in FSUIPC.

I want to call ( execute) a LUA function when I toogle a switch that is defined in SIOC

like:

Var 74 Link IOCARD_SW Input 65 Type I

{
IF v74 = 1
{ call LUA function toggleVORL( or something like this)
}

example of LUA function:

local function toggleVORL(state, unit)

if state == 0 and ipc.readLvar('ngx_switch_358_a') ~= 0 then
ipc.control(69990, -2147483648)
ipc.control(69990, 524288)
ipc.control(69990, -2147483648)
ipc.control(69990, 524288)
elseif state == 1 and ipc.readLvar('ngx_switch_358_a') == 0 then
ipc.control(69990, 536870912)
ipc.control(69990, 131072)
end
else
if state == 0 and ipc.readLvar('ngx_switch_414_a') ~= 0 then
ipc.control(70046, -2147483648)
ipc.control(70046, 524288)
ipc.control(70046, -2147483648)
ipc.control(70046, 524288)
elseif state == 1 and ipc.readLvar('ngx_switch_414_a') == 0 then
ipc.control(70046, 536870912)
ipc.control(70046, 131072)
end
end
end

rgs,

Roar K

deering
11-09-2011, 10:23 AM
Hello Roar.

Not directly, but you could place your arguments in one of FSUIPC's user offsets and use the "intercept" event from the FSUIPC library to drive your LUA script.

Jim

kiek
12-05-2011, 09:16 AM
Hi,
Or you could send an FSControl from SIOC to FSUIPC (http://www.lekseecon.nl/howto.html#fscontrol), or toggle one of the FSUIPC Virtual buttons from SIOC, see keygen part, method 2 (http://www.lekseecon.nl/howto.html#keygen).
regards,
Nico Kaan