Hi Thomas,
Thanks again, really appreciate it, but seems like doesnt work, when i press my button on my joystick , nothing happend (The joynumber and button number is the same), and also i tried to change instead "Rudder To Tiller" to "Rudder to Aileron" because that what i try to achieve (its a typo when i said rudder to tiller, Sorry 😄 ) by change the ipc.control value. here i attached my edited script, Really hope you can help me to see what the matter. Sorry to bother you.
Thanks.
-------------------------------------------------------
-- Lua plug-in for Rudder / Tiller switch --
-------------------------------------------------------
-------------------------------------------------------
-- if 'AutoAssignLetters=Yes' is used then 'joyNumber' is a letter between asterix
-- else it is the number without asterix
-- 'btnNumber' is Button number shown in FSUIPC
-- FS Controls
joyNumber = "A"
btnNumber = 1
-- create Button mask
btnMask = 2^btnNumber
btnPressed = 0
toggleBtn = 0
-- Rudder out value
rudOut = 0
tilOut = 0
setZero = 1
while 1 do
ipc.sleep(20)
if (logic.And(ipc.buttons(joyNumber), btnMask) == 1) then
btnPressed = btnPressed + 1
if (btnPressed == 1 and toggleBtn == 0) then
toggleBtn = 1
setZero = 0
ipc.writeSTR(0x3380, "TILLER CONTROL\0")
ipc.writeSW(0x32FA, 4)
elseif (btnPressed == 1 and toggleBtn == 1) then
toggleBtn = 0
setZero = 0
ipc.writeSTR(0x3380, "RUDDER CONTROL\0")
ipc.writeSW(0x32FA, 4)
end
if btnPressed > 25 then btnPressed = 25 end
else
if btnPressed > 0 then btnPressed = btnPressed - 1 end
end
-- read aileron axis from FS
axisSW = ipcPARAM
-- write to rudder depending of selection
if toggleBtn == 1 then -- write TILLER
diffT = (axisSW - tilOut) / 5
tilOut = tilOut + diffT
ipc.control(65695, tilOut)
if setZero == 0 then
setZero = 1
rudOut = 0
ipc.control(65764, 0)
ipc.log("RUD nCTR")
end
else -- write RUDDER
diffR = (axisSW - rudOut) / 5
rudOut = rudOut + diffR
ipc.control(65764, rudOut)
if setZero == 0 then
setZero = 1
tilOut = 0
ipc.control(65695, 0)
ipc.log("TIL nCTR")
end
end
end
--Aileron 65695
--Steering 66818
--Rudder 65764
RudTilSW.lua