Sign in to follow this  
Skiyzo

Use functions from PMDG linda module who are in actions.lua through FSUIPC

Recommended Posts

Hello,

 

Could you help me please ?

 

How can i use functions who are in actions.lua through FSUIPC ?

actions.lua from : http://www.avsim.com/topic/341971-pmdg-737-ngx-module-47-new/

 

Example in FSUIPC :

Key presses : SET : CTRL + J >>> NGX_PUMP1_AFT_toggle

or

Buttons + Switches : SET : 1 >>> NGX_PUMP1_AFT_toggle

Thanks for help.

 

PS : i have create a specific FSUIPC macro for the test, but i dont want do this for each function.

PMDGBaseVar =     0x00011000        -- 69632
PMDG_ClkL =     0x20000000        -- 536870912
PMDG_ClkR =     0x80000000        -- -2147483648
PMDG_dec =      0x00002000         -- 8192
PMDG_inc =      0x00004000         -- 16384
PMDG_RelL =     0x00020000        -- 131072
PMDG_RelM =     0x00040000        -- 262144
PMDG_RelR =     0x00080000        -- 524288

function NGX_PUMP1_AFT_off ()
if ipc.readLvar('ngx_switch_37_a') ~= 0 then
ipc.control(PMDGBaseVar+37, PMDG_ClkR)
DspShow("PMP1", "Aoff")
end
end

function NGX_PUMP1_AFT_on ()
if ipc.readLvar('ngx_switch_37_a') ~= 100 then
ipc.control(PMDGBaseVar+37, PMDG_ClkL)
DspShow("PMP1", "A on")
end
end
    
if ipc.readLvar('ngx_switch_37_a') == 100 then
NGX_PUMP1_AFT_off()
else
NGX_PUMP1_AFT_on()
end


PS : i have also test an include in lua MACRO file !? But dont still work ?

require("scripts.actions")
NGX_PUMP1_AFT_toggle()
end

Thanks for advance;

 

Sky

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Hello,

 

you can't simply convert them into FSUIPC.

 

And as you have found out, you have to make a LUA script for each function.

 

That was the reason why we have developed LINDA 5 years ago, so that we do not need to handle hundreds of scripts and assigning them via FSUIPC.

Share this post


Link to post
Share on other sites

throught LINDA, can you have like fsuipc a specifique profil for each aircraft ?

How can i program a panel who use keyboard key to send action and who dont appear in linda ?

is Include not possible in LINDA files ?

Thanks

Share this post


Link to post
Share on other sites

Yes, LINDA provides specific profiles. That's why we have different modules here to download.

LINDA supports HID Devices, the only possibility I can think of is to use a software which is emulating keyboard keys into HID outputs ... but I can't promise if that is really working. Never tried it.

 

 

The last question I do not understand, sorry
 

Share this post


Link to post
Share on other sites

thx.

Last question is like php code, could you use "include" in LINDA code. ex : functions are in functions.lua and in macro1.lua you include function.lua to call only the specific function you want who is in functions.lua .

 

 

 

LINDA supports HID Devices, the only possibility I can think of is to use a software which is emulating keyboard keys into HID outputs ... but I can't promise if that is really working. Never tried it.

 

I find vjoy, but you can send key by press a virtual button. I want make the reverse.

 

Do yo know if a software exist for "convert" sendkey in virtual joystick button.

Ex : i make CTRL+G who activate the button N°1 of a virtual joystick ?

 

For information i use : http://www.opencockpits.com/index.php/en/iocards/available-cards/keyboards

 

thx

Share this post


Link to post
Share on other sites

 

 


Last question is like php code, could you use "include" in LINDA code. ex : functions are in functions.lua and in macro1.lua you include function.lua to call only the specific function you want who is in functions.lua .

 

There is a INCLUDE equivalent function called Require. This is a sample taken from LINDA INIT.lua file that loads the library modules:

 

-- loading optional libraries

_log('[iNIT] Loading Libraries...')
if ipc.get("LIBREQ") ~= "" then
     libs = split(ipc.get("LIBREQ"), "#")
     for i, req in pairs(libs) do
          if req ~= nil then
               _logg("[iNIT] loading optional library: " .. req)
               require(req)
         end
    end
end
 
I will leave you to workout whether you can use it. Any code you write should be included in the user.lua file in the LIBS folder so that it won't be overwritten during a LINDA update.

Share this post


Link to post
Share on other sites

This is an example how to assign keyboard shortcuts via FSUIPC using ONE lua file.

 

1. Create a text file in MODULES folder e.g. '737_action.lua'

2. Copy the functions you want into that file, (at the top we put variables), lets take the pumps as example:

PMDGBaseVar = 	0x00011000		-- 69632
PMDG_ClkL = 	0x20000000		-- 536870912
PMDG_ClkR = 	0x80000000		-- -2147483648
PMDG_dec = 	    0x00002000 		-- 8192
PMDG_inc = 	    0x00004000 		-- 16384
PMDG_RelL = 	0x00020000		-- 131072
PMDG_RelM = 	0x00040000		-- 262144
PMDG_RelR = 	0x00080000		-- 524288

function NGX_PUMP1_AFT_on ()
    if ipc.readLvar('ngx_switch_37_a') ~= 100 then
        ipc.control(PMDGBaseVar+37, PMDG_ClkL)
		DspShow("PMP1", "A on")
    end
end

function NGX_PUMP1_AFT_off ()
    if ipc.readLvar('ngx_switch_37_a') ~= 0 then
        ipc.control(PMDGBaseVar+37, PMDG_ClkR)
		DspShow("PMP1", "Aoff")
    end
end

function NGX_PUMP1_AFT_toggle ()
    if ipc.readLvar('ngx_switch_37_a') == 100 then
        NGX_PUMP1_AFT_off()
    else
        NGX_PUMP1_AFT_on()
    end
end


3. Change the lines as below (we can remove the line with 'DspShow' if not using MCP):

PMDGBaseVar = 	0x00011000		-- 69632
PMDG_ClkL = 	0x20000000		-- 536870912
PMDG_ClkR = 	0x80000000		-- -2147483648
PMDG_dec = 	    0x00002000 		-- 8192
PMDG_inc = 	    0x00004000 		-- 16384
PMDG_RelL = 	0x00020000		-- 131072
PMDG_RelM = 	0x00040000		-- 262144
PMDG_RelR = 	0x00080000		-- 524288

-- NGX_PUMP1_AFT_on
if ipcPARAM == 0 then
    if ipc.readLvar('ngx_switch_37_a') ~= 100 then
        ipc.control(PMDGBaseVar+37, PMDG_ClkL)
   end
end

-- NGX_PUMP1_AFT_off
if ipcPARAM == 1 then
    if ipc.readLvar('ngx_switch_37_a') ~= 0 then
        ipc.control(PMDGBaseVar+37, PMDG_ClkR)
    end
end

--NGX_PUMP1_AFT_toggle
if ipcPARAM == 2 then
    if ipc.readLvar('ngx_switch_37_a') == 100 then
        NGX_PUMP1_AFT_off()
    else
        NGX_PUMP1_AFT_on()
    end
end

Assign the shortcuts as below changing the parameter field accordingly:

 

AqdDClf.jpg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this