Sliders not working?
-
- Posts: 69
- Joined: Mon Sep 13, 2021 3:21 am
Sliders not working?
Using a simple slider to test (the example in the slider tutorial video), I'm gettting the hand (fist closed) on hover. Any attempt to click and move results in the window moving.
Is there something special that needs to enabled to make sliders work?
AM Desktop 4.0.2 MacOS 11.4
Is there something special that needs to enabled to make sliders work?
AM Desktop 4.0.2 MacOS 11.4
Last edited by Mickolodias on Wed Sep 15, 2021 11:17 pm, edited 1 time in total.
I'm one of 'those' mac guys. (and I have no idea why I can't afford to eat)
Re: Silders not working?
There are quite a few instruments using sliders, so I don't think there is anything wrong with the slider. So probably your implementation is wrong
-
- Posts: 69
- Joined: Mon Sep 13, 2021 3:21 am
Re: Silders not working?
Nah there's something fishy.
Funny thing is I actually got it to move once and output to the console and x-plane (no code chenges!). But 5 minutes of trying dragging, clicking, clicking away etc etc I haven't been able to get it move again.
I can email a video of my attempt if it helps
Funny thing is I actually got it to move once and output to the console and x-plane (no code chenges!). But 5 minutes of trying dragging, clicking, clicking away etc etc I haven't been able to get it move again.
I can email a video of my attempt if it helps
Code: Select all
function new_mixture(val)
slider_set_position(slider_mixture, val[1])
end
xpl_dataref_subscribe("sim/cockpit2/engine/actuators/mixture_ratio", "FLOAT[8]", new_mixture)
function set_mixture(val)
print(val)
xpl_dataref_write("sim/cockpit2/engine/actuators/mixture_ratio","FLOAT", val, 1)
slider_set_position(slider_mixture, val)
end
slider_mixture = slider_add_ver(nil, 0, 0, 50, 100, "R44_Mixture_Handle.png", 49, 49, set_mixture)
I'm one of 'those' mac guys. (and I have no idea why I can't afford to eat)
Re: Silders not working?
Your script is fishy Have a good look at it.
Re: Silders not working?
Couple of things I notice with the code.
The slider is right up against the edge of the instrument. Can you try making the instrument a little bigger and keeping the slider size well within the bounds of the instrument. Let us know how that goes.
Not the issue but you are setting the slider position in 2 places. Remove the position setting from the slider callback if you are using the data subscribe from the sim to set its position.
I also noticed you are on Mac which might be nothing of significance in this case but worth note that most AM users are running Win10 because it’s generally easier for a sim setup. The tutorial videos were produced on a Win10 machine.
The slider is right up against the edge of the instrument. Can you try making the instrument a little bigger and keeping the slider size well within the bounds of the instrument. Let us know how that goes.
Not the issue but you are setting the slider position in 2 places. Remove the position setting from the slider callback if you are using the data subscribe from the sim to set its position.
I also noticed you are on Mac which might be nothing of significance in this case but worth note that most AM users are running Win10 because it’s generally easier for a sim setup. The tutorial videos were produced on a Win10 machine.
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Re: Silders not working?
The whole xpl writing is done wrong. See the attached (siff) example. You can import it in the Create/Edit tab.
Have a good look at the example how the xpl write should be done if you're working with arrays. The script used in the example:
Have a good look at the example how the xpl write should be done if you're working with arrays. The script used in the example:
Code: Select all
function set_mixture(position)
xpl_dataref_write("sim/cockpit2/engine/actuators/mixture_ratio", "FLOAT[8]", {1 - position})
end
slider_mixture = slider_add_ver(nil,125,50,47,200, "silder.png", 50, 105, set_mixture)
function new_mixture(position)
slider_set_position(slider_mixture , 1 - position[1])
end
xpl_dataref_subscribe("sim/cockpit2/engine/actuators/mixture_ratio", "FLOAT[8]", new_mixture)
-
- Posts: 69
- Joined: Mon Sep 13, 2021 3:21 am
Re: Silders not working?
Thanks for the great ideas!
Sling - yep tried making the instrument bigger and putting the slider in the middle long before I posted And since tried again with no luck
I also progressivly commented out code until I had just with print(val) on the slider, no send/subscribe - still no luck. I figured I should get at least 1 line in the console when I click or drag on the handle
Ralph
What's a .siff file?
But copied and pasted your code, only thing I changed was the image reference - and doesn't work, silder won't budge!
Is there some kind of logging I can send to you?
And thanks for the xpl heads up - I looked at the arguments only in wiki (which says attribute 3 is a number), skipped the example - that'll teach me.
Shouldn't it be:
Sling - yep tried making the instrument bigger and putting the slider in the middle long before I posted And since tried again with no luck
I also progressivly commented out code until I had just with print(val) on the slider, no send/subscribe - still no luck. I figured I should get at least 1 line in the console when I click or drag on the handle
Ralph
What's a .siff file?
But copied and pasted your code, only thing I changed was the image reference - and doesn't work, silder won't budge!
Is there some kind of logging I can send to you?
And thanks for the xpl heads up - I looked at the arguments only in wiki (which says attribute 3 is a number), skipped the example - that'll teach me.
Shouldn't it be:
Code: Select all
xpl_dataref_write("sim/cockpit2/engine/actuators/mixture_ratio", "FLOAT[8]", {position[1]}, 0)
I'm one of 'those' mac guys. (and I have no idea why I can't afford to eat)
Re: Silders not working?
Read Ralph's post again .... He includes the 'siff' file for you to download. He also says IMPORT the siff file, not copy and paste the code from the post.
Ps - what is a 'mac' ??? (just joking) ..
Ps - what is a 'mac' ??? (just joking) ..
Joe. CISSP, MSc.
Re: Silders not working?
Like jph said, import the siff file (read my post).
The dataref write example you posted is again, incorrect.
Don't use [1]. And in this case you don't need an offset, so you don't have to use the , 0. So:
I used my example with the default Cessna 172. Your R44 might very well be using a different dataref. I have assigned joystick axis to the R44 from Vskylabs once, for the mixture it used something entirely different than mixture. You'll have to check with the dataref viewer.
The dataref write example you posted is again, incorrect.
Don't use [1]. And in this case you don't need an offset, so you don't have to use the , 0. So:
Code: Select all
xpl_dataref_write("sim/cockpit2/engine/actuators/mixture_ratio", "FLOAT[8]", {position})
-
- Posts: 69
- Joined: Mon Sep 13, 2021 3:21 am
Re: Sliders not working?
.siff, ah, I see. Imported the code silder still doesn't nove
Lets take a really simple example. Using this, slider still does not budge, nor is anything appearing in the console
Argh 2 topics in 1:
In my case - I'm taking taking the first element, and writing to the first element only in x-plane no?
Is see how your example works - Maybe this a lua thing - if position is already an array, shouldn't you be able to go without the {}.?
And honestly no idea why I keep writing silder. Maybe because it's 1am here lol
Lets take a really simple example. Using this, slider still does not budge, nor is anything appearing in the console
Code: Select all
function set_mixture(position)
print(position)
end
slider_mixture = slider_add_ver(nil,125,50,47,200, "silder.png", 50, 105, set_mixture)
Argh 2 topics in 1:
In my case - I'm taking taking the first element, and writing to the first element only in x-plane no?
Is see how your example works - Maybe this a lua thing - if position is already an array, shouldn't you be able to go without the {}.?
And honestly no idea why I keep writing silder. Maybe because it's 1am here lol
I'm one of 'those' mac guys. (and I have no idea why I can't afford to eat)