Jump to content
The simFlight Network Forums
johnk515

Lua file doesn't work for Carenado Phenom 100

Recommended Posts

I got a lua file from Bruce Buckley in the Carenado Phenom 100 so I could the taxi/landing light switch to a button.

-- Parameters by Number
--------------------------------------------
-- 1    Move Ldg_Taxi Lt SW UP one position  --  E50P
-- 2    Move Ldg_Taxi Lt SW DN one position  --  E50P
-- 3    Turn ON NAV & STROBE Lts             --  E50P, PA28, C172
-- 4    Turn OFF NAV & STROBE Lts             --  E50P, PA28, C172
-- 5    Turn ON Fuel Pump                       --  PA28, C172
-- 6    Turn OFF Fuel Pump                     --  PA28, C172
 
--------------------------------------------
---- Variables
--------------------------------------------
    SW_Pos      = "L:ASD_SWITCH_LANDING_TAXI_EMB500"
 
--------------------------------------------
---- Scripts
--------------------------------------------
 
-- Move Ldg_Taxi Lt SW UP one position
if ipcPARAM == 1 then
    SWPos = ipc.readLvar(SW_Pos)
    if SWPos == 0 then
        ipc.writeLvar(SW_Pos, 1) 
        ipc.setbitsUW(0x0D0C, 8) 
    end
    if SW_os == 1 then
        ipc.writeLvar(SW_Pos, 2)
        ipc.clearbitsUW(0x0D0C, 8)        
        ipc.setbitsUW(0x0D0C, 4)
    end
end
 
-- Move Ldg_Taxi Lt SW DN one position
if ipcPARAM == 2 then
   SWPos = ipc.readLvar(SW_Pos)
    if SWPos == 2 then
        ipc.writeLvar(SW_Pos, 1) 
        ipc.clearbitsUW(0x0D0C, 4)            
        ipc.setbitsUW(0x0D0C, 8)     
    end
    if SWPos == 1 then
        ipc.writeLvar(SW_Pos, 0) 
        ipc.clearbitsUW(0x0D0C, 8)
    end
end

This is the script that I got.  I left out the ones for variable 3-6.  But nothing happens when I try it.  Here's the lua log that comes up.

********* LUA: "Luacmds" Log [from FSUIPC version 4.971] *********
   314391 System time = 30/08/2017 14:42:02, Simulator time = 14:37:27 (21:37Z)
   314391 LUA: beginning "D:\Steam\steamapps\common\FSX\Modules\Luacmds.lua"
   314391 *** LUA Error: D:\Steam\steamapps\common\FSX\Modules\Luacmds.lua:1: unexpected symbol near ' '
   314391 >>> Thread forced exit (ipc.exit or os.exit) <<<
   314391 System time = 30/08/2017 14:42:02, Simulator time = 14:37:27 (21:37Z)
********* LUA execution terminated: Log Closed *********
********* LUA: "Luacmds" Log [from FSUIPC version 4.971] *********
   315188 System time = 30/08/2017 14:42:03, Simulator time = 14:37:28 (21:37Z)
   315188 LUA: beginning "D:\Steam\steamapps\common\FSX\Modules\Luacmds.lua"
   315203 *** LUA Error: D:\Steam\steamapps\common\FSX\Modules\Luacmds.lua:1: unexpected symbol near ' '
   315203 >>> Thread forced exit (ipc.exit or os.exit) <<<
   315203 System time = 30/08/2017 14:42:03, Simulator time = 14:37:28 (21:37Z)
********* LUA execution terminated: Log Closed *********
********* LUA: "Luacmds" Log [from FSUIPC version 4.971] *********
   347766 System time = 30/08/2017 14:42:36, Simulator time = 14:37:42 (21:37Z)
   347766 LUA: beginning "D:\Steam\steamapps\common\FSX\Modules\Luacmds.lua"
   347766 *** LUA Error: D:\Steam\steamapps\common\FSX\Modules\Luacmds.lua:1: unexpected symbol near ' '
   347766 >>> Thread forced exit (ipc.exit or os.exit) <<<
   347766 System time = 30/08/2017 14:42:36, Simulator time = 14:37:42 (21:37Z)
********* LUA execution terminated: Log Closed *********
********* LUA: "Luacmds" Log [from FSUIPC version 4.971] *********
   349000 System time = 30/08/2017 14:42:37, Simulator time = 14:37:43 (21:37Z)
   349000 LUA: beginning "D:\Steam\steamapps\common\FSX\Modules\Luacmds.lua"
   349000 *** LUA Error: D:\Steam\steamapps\common\FSX\Modules\Luacmds.lua:1: unexpected symbol near ' '
   349000 >>> Thread forced exit (ipc.exit or os.exit) <<<
   349000 System time = 30/08/2017 14:42:37, Simulator time = 14:37:43 (21:37Z)
********* LUA execution terminated: Log Closed *********
Bruce says it works for him and many others.  I'm using steam, but I have other lua files that work just fine.  Any ideas what the problem is?
 

 

Share this post


Link to post
Share on other sites

John,

Did you check for typos as I suggested?  I see at least one.

"if SW_os == 1 then"  should be "if SWPos == 1 then"  in the "-- Move Ldg_Taxi Lt SW UP one position" routine.  That's why I asked you to send me the file.  I know the script works in FSX and in P3DV4.  Fix that typo and let us know if it works then.

Bruce

Share this post


Link to post
Share on other sites

Hi,

it might be better to attach the file rather than copy its content to find the error, as it says the error is in line 1 near quotes but the copied lines don't contain any quotes.

Thomas

Share this post


Link to post
Share on other sites

Hi,

I did run that Lua file and got as well the error. So I went through the file and removed all spaces (or what ever symbol was actually behind it) and replaced it with tabs and spaces (32).

Now it loads without any error, just try if the file works for you as well.

Luacmds.lua

Thomas

Share this post


Link to post
Share on other sites

Hello johnk515

You should look for special chars in your script . I think a0 can not be handled.

Luacmds.lua script first five lines in HEX

a0 20 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  . ..------------
2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
20 0d 0a 2d 2d 20 53 63 72 69 70 74 73 20 66 6f   ..-- Scripts fo
72 20 73 70 65 63 69 61 6c 20 73 77 69 74 63 68  r special switch

Thomas
P.s.

you have 204 x a0 in your script. In HTML the meaning is protected space

If you have copied from a browser, this is not uncommon.

Share this post


Link to post
Share on other sites

Hello Thomas,

for your information only ..

your cleanup from spaces new .lua file you accidentally removed the S

Line 41 ...

-- Move Ldg_Taxi Lt SW DN one position
if ipcPARAM == 2 then
    WPos = ipc.readLvar(SW_Pos)       <-------------  WPos should be SWPos
    if SWPos == 2 then
        ipc.writeLvar(SW_Pos, 1)
        ipc.clearbitsUW(0x0D0C, 4)
        ipc.setbitsUW(0x0D0C, 8)
    end
    if SWPos == 1 then
        ipc.writeLvar(SW_Pos, 0)
        ipc.clearbitsUW(0x0D0C, 8)
    end
end

------------------------------------------------------------------

And also take care 73 x a0 are left in the file !
Is only a question of the time, when by editing an a0 into a wrong position comes.

servus
Thomas

Share this post


Link to post
Share on other sites

https://www.avsim.com/forums/topic/518118-offsets-for-switches-phenom-100-fsuipc/#comment-3701089

FYI. The topic at AVSIM where I posted the script in a post and also posted a link to download the Lua file.  If the file is downloaded and placed in the modules folder it should work correctly. It must have been copied from the post in a browser. 

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

×

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.