Jump to content
The simFlight Network Forums

Recommended Posts

Posted

I am not a programmer. Try as I might, programming languages are all Greek to me. I took a course in Basic while in grad school. The only way I got through it was with lots of help from a friend. That being said, I have managed to hack my way through simple Lua files to activate Lvars through cockpit switches. My goal is to have P3D to recognize the switch positions for Parking Brakes and canopy/door in the cockpit and set the corresponding offsets to match the switches. However, right now I simply want to get the offset to match the switches by using PARMS assigned to the SPST switches  Using examples I found on the internet and reading what I can understand I cobbled together a script I thought  would work. It doesn't! FSUIPC does recognize and allowed me to set the switches. Would someone be so kind as to help lead an old man out of the darkness. Here is the script.

 

Thanks,

John

-- PBNC Parking Brake & Canopy Initialization

-- John Miguez

-- Paramenters


-- 1            Park Brake off
-- 2            Park Brake on
-- 3            Canopy  OPEN
-- 4            Canopy  CLOSE

-- Variables
-- Park_Brake        = 0x0BC8        -- FSUIPC Offset Values 0=OFF 32767=ON
-- Canopy              = 0x3367        -- FSUIPC Offset Values 0=OFF 1=ON

- Parking Brakes Set

if ipcPARAM == 1 then
    ipc.writeUW(0BC8,0)
end

if ipcPARAM == 2 then
  ipc.writeUW(0BC8,32767)
end


-- Canopy OPEN

if ipcPARAM == 3 then
  ipc.writeUW(3367,1)
 
end

-- Canopy CLOSE

if ipcPARAM == 4 then
  ipc.writeUW(3367,0)

end
end

Posted
2 minutes ago, jmig said:

Here is the script.

The offsets you are using are hexadecimal, so should be represents with the prefix 0x. You appear to have recognised that in these comments:

-- Park_Brake        = 0x0BC8        -- FSUIPC Offset Values 0=OFF 32767=ON
-- Canopy              = 0x3367        -- FSUIPC Offset Values 0=OFF 1=ON

but then you've omitted them in the ipc.writeUW calls. I would have thought it would give errors when you tried to execute it. did you check the FSUIPC log?

One other thing. The doors offset 0x3367, is only a Byte, so for writes to that you should use ipc.writeUB.

Pete

 

 

Posted

Thank you, sir,

I (think) I made the changes you suggesed. However, it didn't work. Here is the modified script and the FSUIPC log.

 


-- Paramenters


-- 1            Park Brake off
-- 2            Park Brake on
-- 3            Canopy Switch OPEN
-- 4            Canopy Switch CLOSE

-- Variables
Park_Brake        = 0x0BC8        -- FSUIPC Offset Values 0=OFF 32767=ON
Canopy_Set      = 0x3367        -- FSUIPC Offset Values 0=OFF 1=ON

- Parking Brakes Set

if ipcPARAM == 1 then
    ipc.writeUW(0x0BC8,0)
end

if ipcPARAM == 2 then
  ipc.writeUW(0x0BC8,32767)
end


-- Canopy Switch OPEN

if ipcPARAM == 3 then
  ipc.writeUB(0x3367,1)
 
end

-- Canopy Switch CLOSE

if ipcPARAM == 4 then
  ipc.writeUB(0x3367,0)

end
end

 

FSUIPC6.log

Posted

Update. I founld the Line 17 error and fixed it. Now I am getting a different error. I am afraid that I have no idea what this means. I will keep looking, however.

 

238843 *** LUA Error: C:\Users\john\Documents\Prepar3D v4 Add-ons\FSUIPC6\PBNC.lua:41: '<eof>' expected near 'end'
   239281 *** LUA Error: C:\Users\john\Documents\Prepar3D v4 Add-ons\FSUIPC6\PBNC.lua:41: '<eof>' expected near 'end'
   240203 *** LUA Error: C:\Users\john\Documents\Prepar3D v4 Add-ons\FSUIPC6\PBNC.lua:41: '<eof>' expected near 'end'
   241156 *** LUA Error: C:\Users\john\Documents\Prepar3D v4 Add-ons\FSUIPC6\PBNC.lua:41: '<eof>' expected near 'end'
   247500 === Closing session: waiting for DLLStop to be called ...
   260859 === DLLStop called ...

Posted

Update to the update. It is working 🙂 Thank you so much for pointing me the right direction and the correction on the UW vs UB. You may not have an idea of how good I feel at the moment. I finally got one of these FM scripts to work.

 

John

Posted
2 hours ago, jmig said:

I founld the Line 17 error and fixed it.

Sorry, not seeing the plug-in file itself I've no idea which is "line 17".

2 hours ago, jmig said:

Update to the update. It is working

Good! Well done! 😉

Pete

 

 

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
×
×
  • Create New...

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.