Does anything in a plugin need to be global? I have a simple plugin that does a call_delay and has a few actions. Nothing beyond that. When defining the functions and variables, does anything need to be global? Or should everything be local? It’s not clear to me if the call_delay needs any special handling, or the startup/initialization functions and other action functions need to be global.
Side question: when call an lua function with no variables, do you need the “()”? I’ve seen the startup/initialization in the implementation XML without the parentheses, but it looks a little odd to me.
Yes. Any of the callback functions require the name of a global function which will handle the callback. This is true for call_delay(), call_timer(), register_handler(), job_watch(), variable_watch(), …
Otherwise, make everything local.
Side question: when call an lua function with no variables, do you need the "()"? I've seen the startup/initialization in the implementation XML without the parentheses, but it looks a little odd to me.
What’s in the XML is just a name, it’s not the actual call to the function, it’s not Lua.
Yes, you always need the (), unless you are using " ", ’ ', or [[ ]] for string parameters, or {} for tables:
print "hello"
print 'there'
print [[yes, this works]]
local x = table.concat {1,2,3}
print (x)
Ah, okay. But is there a difference between the XML startup tag, and the run tag inside an action? The latter appears to be true lua, correct?
The reason I’m asking is that I want to place the action code in a L_xxx.lua file so I am planning on placing a function call (only) in the I_xxx.xml file and have the body of the function in the L file. So I think I need it as “myFunc()” as the call in the run tag. Is that right? Thanks.