Sliders not working?

Discuss suspected bugs with other users and Sim Innovations Staff

Moderators: russ, Ralph

Message
Author
Mickolodias
Posts: 69
Joined: Mon Sep 13, 2021 3:21 am

Sliders not working?

#1 Post by Mickolodias »

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
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)

User avatar
Ralph
Posts: 7878
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Silders not working?

#2 Post by Ralph »

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 :)

Mickolodias
Posts: 69
Joined: Mon Sep 13, 2021 3:21 am

Re: Silders not working?

#3 Post by Mickolodias »

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

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)
silder.png
silder.png (5.64 KiB) Viewed 3066 times
I'm one of 'those' mac guys. (and I have no idea why I can't afford to eat)

User avatar
Ralph
Posts: 7878
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Silders not working?

#4 Post by Ralph »

Your script is fishy :mrgreen: Have a good look at it.

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

Re: Silders not working?

#5 Post by Sling »

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.

User avatar
Ralph
Posts: 7878
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Silders not working?

#6 Post by Ralph »

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.
R44 - Mixture.siff
(7.87 KiB) Downloaded 154 times
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)

Mickolodias
Posts: 69
Joined: Mon Sep 13, 2021 3:21 am

Re: Silders not working?

#7 Post by Mickolodias »

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:

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)

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Silders not working?

#8 Post by jph »

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' ??? :shock: (just joking) .. :mrgreen:
Joe. CISSP, MSc.

User avatar
Ralph
Posts: 7878
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Silders not working?

#9 Post by Ralph »

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:

Code: Select all

xpl_dataref_write("sim/cockpit2/engine/actuators/mixture_ratio", "FLOAT[8]", {position})
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.

Mickolodias
Posts: 69
Joined: Mon Sep 13, 2021 3:21 am

Re: Sliders not working?

#10 Post by Mickolodias »

.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

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)

Post Reply