Confusion about `print`?

I feel like I’m missing something obvious here. When I run a script like the following (a slightly modified example script):

-- Change colour of the control according to its value

-- The color of the control changes to orange when above
-- a threshold given by the Lua script

-- declare a global threshold variable
threshold = 96

print("Apply color script")

function applyColor (valueObject, value)
  print("changing color")
  local control = valueObject:getControl ()
  if (value <= threshold) then
    control:setColor (WHITE)
    control:setColor (ORANGE)

I see a log message for my first global print statement (lua: Apply color script), but I don’t see a log item for the print statement in the applyColor callback. I’ve tried numerous copy-paste examples from the documentation that have print statements in callbacks, but I never seem to see any results.

What am I missing?

the first print statement is outside any function, so as soon as the preset+LUA gets loaded and parsed, it will get printed out.

If the second one isn’t seen, it usually that happens to me when either

a) the function is actually never called, or
b) I have a syntax error in that routine being called

I can confirm that there are no syntax errors, and the function is being called: with the example I posted, the color of the control does change when the value passes threshold, so it’s definitely being called.

Hi, it looks like you have your logger output disabled. It can be enabled/disabled with a SysEx call, see
system-logger-on.syx. And documentation at SysEx implementation | Logger enable/disable.

I will add remark about that to the example scripts. It is for the second time that somebody was wasting time on that. And I will point that out in the Lua extension docs.

1 Like

Thanks! I figured it was something like this.

Just wanted to give this tip :sweat_smile:

1 Like