Lukas wrote:Is there something I should know about regarding these two lines of code I'm using?
Line for disabling the 'Paths' checkbox under 'Display quality':
Code: Select all
view:SetQualityFlags(MOHO.clearbit(view:QualityFlags(), MOHO.LDQ_WIREFRAME))
Line for enabling the 'Paths' checkbox under 'Display quality':
Code: Select all
view:SetQualityFlags(MOHO.setbit(view:QualityFlags(), MOHO.LDQ_WIREFRAME))
When I run them on my own computers (both on a Windows 10 machine and on a Macbook Pro running OS X Mojave), they don't always work. (I'm running the code when I press a toolbar button, which always works on all computers, and I'm running the code when I enter and exit frame 0, which used to work in the past (not sure what changed, maybe it was 12.4 or some Windows update, but not anymore)
But here comes the weirdest part, when I'm using my tool on another Windows computer, it works fine when leaving and exiting frame 0. They are both using the exact same Custom Content Folder. Tested it with the same project files too.
Is there something in MOHO.clearbit/setbit that I don't understand that can behave different on different machines in different situations?
I assume that you'd need to provide MOHO.LDQ_WIREFRAME to MOHO.clearbit/MOHO.setbit as a
MOHO.bit:
view:SetQualityFlags(MOHO.clearbit(view:QualityFlags(),
MOHO.bit(MOHO.LDQ_WIREFRAME
)))
And then depending on how you are running it when entering/exiting frame zero, it may be running more than once. So if you're doing a check, like this...
Code: Select all
if (MOHO.hasbit(view:QualityFlags(), MOHO.bit(MOHO.LDQ_WIREFRAME))) then
view:SetQualityFlags(MOHO.clearbit(view:QualityFlags(), MOHO.bit(MOHO.LDQ_WIREFRAME)))
else
view:SetQualityFlags(MOHO.setbit(view:QualityFlags(), MOHO.bit(MOHO.LDQ_WIREFRAME)))
end
...it may be working, but being run a different number of times (odd or even) on different systems. You might need to make sure the code only runs once.
If all else fails, there's also doing it brute force, instead of bitwise:
Code: Select all
local flags = {4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2}
local qual = moho.view:QualityFlags()
local tempQual = qual
for i,v in ipairs(flags) do
if (tempQual >= v) then
tempQual = tempQual-v
end
if (tempQual == 2) then
moho.view:SetQualityFlags(qual-2)
break
end
if (i == #flags) and (tempQual ~= 2) then
moho.view:SetQualityFlags(qual+2)
break
end
end