TouchOSC Scripting

  • TimelockButton: Add this lua code to button widget to lock the button for spicific times.
    
-- how long should this button being locked
local locktime = 3

-- don't change following properties
local one_sec = 1000
local last = 0

function init()
      self.properties["release"] = false
      self.values["x"] = 0
end

function update()
      if (getMillis() - last) > (locktime * one_sec) and (self.values["x"] == 1) then
            self.values["x"] = 0
            print("Unloack")
      end
end

function onValueChanged(key)
      if (key == "x") and (self.values["x"] == 1) then
            last = getMillis()
            print(self.ID .. " Locked for " .. locktime .. " Seconds")
      end
end