When calling fget without a flag index, how can you translate
the bitfield returned by fget back into it's respective flag index (0-7)?
3
flags=fget(sprite_index) flag_0=(flags & 1 != 0) flag_1=(flags & 2 != 0) flag_2=(flags & 4 != 0) flag_3=(flags & 8 != 0) flag_4=(flags & 16 != 0) flag_5=(flags & 32 != 0) flag_6=(flags & 64 != 0) flag_7=(flags & 128 != 0) n=3 flag_n=(flags & (1<<n) !=0) |
@Bee_Randon Note that a sprite can have any and all of the eight flags, so there's really no getting the index of "THE" flag since it's not necessary unique.
If for some reason your sprites all have exactly one flag, use a lookup table with the 8 possible values.
worth noting that the button symbols are tied to the index of their bit flags, so for example (btn()&(1<<🅾️))!=0
is roughly equivalent to btn(🅾️)
(I believe)
[Please log in to post a comment]