BUTTON STRIP : how to query their values in hscript?

   Views 2260   Replies 5   Subscribers 1
User Avatar
Member
65 posts
Joined: April 2020
Offline
if you query the button's values, it appears to only return a single int, and that int is the added results of all the pressed buttons.

for example:
none pressed = 0
button1 = 1
button2 = 2
button3 = 4
button4 = 8
button1 + button4 = 9
button2 + button3 + button4 = 14

i can't imagine putting in a gazillion if statements for all the possible numbers that could indicate if button2 was currently pressed, so i wonder if i'm missing something about this.

the query is this:
ch("../null1/Masks")

i've tried other ways of querying the value in an array or dict manner but all failed...

but no way can a multiple choice button be this difficult to use....!?

thanks in advance!
-seneca
User Avatar
Member
9130 posts
Joined: July 2007
Offline
multichoice buttonstrips or iconstrips are represented as bitfield
use bittest() to check which bit is on
it will return 1 if the bit in question is on and 0 if off (meaning if the button is on or off)

to check if first button (0) is on do:
bittest(ch("../null1/Masks"), 0)
second button (1):
bittest(ch("../null1/Masks"), 1)
third button (2):
bittest(ch("../null1/Masks"), 2)
fourth button (3):
bittest(ch("../null1/Masks"), 3)
fifth button (4):
bittest(ch("../null1/Masks"), 4)
...
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
65 posts
Joined: April 2020
Offline
thank you so much! i knew there had to be a sane way to query their values. i wish this stuff was easier to find in the docs.
User Avatar
Member
65 posts
Joined: April 2020
Offline
hmm. how would you use this in a gui's HIDE WHEN field ?

this doesn't appear to work :

{ bittest(cow,0) == 1 }
User Avatar
Member
5 posts
Joined: Sept. 2023
Offline
indigosm
hmm. how would you use this in a gui's HIDE WHEN field ?

this doesn't appear to work :

{ bittest(cow,0) == 1 }
5 years later and i ran into the same issue. based on my readings, It seems like the field just doesn't support bittest()function.I solved it by creating one with a proxy parameter. hope it helps! (and anyone who came across this in the future)

here's a gif on how I did it:
https://i.imgur.com/Ic0j68Q.gif [i.imgur.com]



Edited by Irene_Howard - April 16, 2025 19:36:19

Attachments:
Enter_a_filename.png (72.0 KB)
NVIDIA_Overlay_eTE8nkZ0Ji.gif (610.9 KB)

User Avatar
Member
65 posts
Joined: April 2020
Offline
Irene_Howard
query the button's values, it appears to only return a single int, and that int is the added results of all the pressed buttons.
awesome! now if only i could remember what tool i was using a button strip in..... hahaha.
  • Quick Links