Emile B. 0 Posted January 14 Report Share Posted January 14 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. Quote Link to post Share on other sites
spokes2112 35 Posted January 14 Report Share Posted January 14 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 Quote Link to post Share on other sites
Emile B. 0 Posted January 15 Author Report Share Posted January 15 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. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.