Block functions from running at program start #484
dnaldoog
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Usually
if panel:getBootStrapState() then return end
will stop lua code from running at startup when declared in Called when the modulator value changes.Problem
I have found that sometimes adding this code at the beginning of a function sometimes doesn't work properly in restricted instances i.e. static versions of a panel. https://ctrlr.org/forums/topic/standalone-images-not-loading/#post-98147
Solution
Create a class initialisation in a constructor function Called before any modulators are created
myPanel = Panel -- stop functions from loading when the panel is loaded
myPanel:_init(true)
This code sets myPanel:setBootstrapState() -- to true
unBlock = function(--[[ CtrlrModulator --]] mod, --[[ number --]] value, --[[ number --]] source)
-- will be fired off on panel load; stops functions from firing off on boot
timer:setCallback(111, TimerCallback) -- TimerId 0
timer:startTimer(111, 500) -- Timer Id 0 500ms
end
This timer sets myPanel:setBootstrapState() -- to false
Place the following code at the beginning of each callback function Called when the modulator value changes.
if myPanel:getBootStrapState() then return end
Functions are now cleared to run.
NOTE: When opening the same panel twice into Ctrlr , popup windows in protected functions will still fire: Block them by checking if source==4.
if source==4 then
utils.warnWindow("","")
end
Class code
myPanel Script Blocker_1_0.zip
Beta Was this translation helpful? Give feedback.
All reactions