game controller

Latest Information on Sim Innovation's flagship product Air Manager

Moderators: russ, Ralph

Message
Author
User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: game controller

#11 Post by Sling »

Good. You don’t need all that code that I posted. It was just in there to help show what is happening. Remember to remove the prints.

maak_pk
Posts: 27
Joined: Sun Dec 13, 2020 11:37 am
Location: Pakistan

Re: game controller

#12 Post by maak_pk »

sure thanks a lot

maak_pk
Posts: 27
Joined: Sun Dec 13, 2020 11:37 am
Location: Pakistan

Re: game controller

#13 Post by maak_pk »

hi
can some go through my code and check y my rd function is not called with change in Thr and new_rd
what wrong am i doing kindly someone point it out
regards

Code: Select all

new_elv=0
new_alr=0
new_col=0
new_rd=0
rd=0
Thr=0
function callback(type, index, value)
print("Type = " .. type .. ", Index = " .. index .. ", Value = " .. value)

if index==1 then
new_elv= value
print("elv"..new_elv)
elseif index==0 then

new_alr=value
print("alr"..new_alr)
elseif index==2 then
new_col=value
print("col"..new_col)
elseif index==3 then
new_rd=value
print("rd"..new_rd)
end
end

function thr(thr)
Thr=thr
print ("thr"..Thr)
end


function rd()
R=(Thr/100)+new_rd
print ("RD"..R)
fsx_variable_write("RUDDER POSITION", "position", R)
end

list = game_controller_list()

for k, v in pairs(list) do
print(v)
if v == "Logitech Extreme 3D" then game_controller_add(v, callback) end
end

fsx_variable_subscribe("GENERAL ENG THROTTLE LEVER POSITION:1", "percent", thr)
rd()

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: game controller

#14 Post by Sling »

You are not calling rd everytime Thr updates. That is why it does not work. The rd() call needs to be inside the Thr callback for it to be run everytime the throttle changes.

This is quite basic stuff you are asking. I would suggest you spend some time studying the instrument API pages of the wiki and watch through the tutorial videos. This will help you moving forward.

maak_pk
Posts: 27
Joined: Sun Dec 13, 2020 11:37 am
Location: Pakistan

Re: game controller

#15 Post by maak_pk »

thanks a lot yes i need to spend sometime on it.

Post Reply