Emile B. Posted January 14, 2021 Report Posted January 14, 2021 Hi Pete & John, A Lua plug-in I set up for the A2A C172 contains the following function : function C172_Door_Open_If_Closed() local doors doors = ipc.readUB(0x3367) if logic.And(doors,1) == 0 -- pilot door closed and ipc.readUB(0x0366) == 1 -- aircraft on ground then ipc.setbitsUB(0x3367, 1) end -- doors = ipc.ask("Which door?\n1=Pilot\n2=Pax\n3=Both") -- 1 = pilot, 2 = passenger, 3 = both -- if doors = 1 or doors = 2 or doors = 3 then -- check input is valid -- if ipc.readUB(0x0366) == 1 -- aircraft on ground -- then -- ipc.setbitsUB(0x3367, doors) -- end -- end end event.flag(54, "C172_Door_Open_If_Closed") The active section works fine. But I thought it would be handy to be able to select which door to open without having to edit the Lua script. So I replaced the active section below the "local doors" line with the section marked as Remarks above. Unfortunately no window to enter the door selection appears. Debug did not show a syntax error so it must be my logic (or more likely, the lack of it). Perhaps I cannot use a string as a mask to set a bit in offset 3367 and if so, how can I fix that ? Can you help put me on the right track ? Using FSUIPC 6.0.12 (registered) with P3DV4.5 HF3. Thanks for any hints. Regards, Emile.
spokes2112 Posted January 14, 2021 Report Posted January 14, 2021 3 hours ago, Emile B. said: Unfortunately no window to enter the door selection appears. No clue on this one. Perhaps the errors below fail the whole lua. IIRC the ipc.ask() returns a string so you could do this 1 of 2 ways - 1) Put this line under ipc.ask() and change your comparison signs in the then following line from = to == & you should be good the rest of the way : doors = tonumber(doors) -or- 2) Change the following 2 lines to first, test against a string & correct the comparison signs, and second, to convert to number for ipc.setbits if doors == "1" or doors == "2" or doors == "3" then -- check input is valid ipc.setbitsUB(0x3367, tonumber(doors)) Hope this helps, Roman 1
Emile B. Posted January 15, 2021 Author Report Posted January 15, 2021 20 hours ago, spokes2112 said: 1) Put this line under ipc.ask() and change your comparison signs in the then following line from = to == & you should be good the rest of the way : doors = tonumber(doors) Yes, that worked a treat ! Many thanks indeed ! Regards, Emile.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now