Can I share this recent revelation without being shamed by my ignorance that this is, perhaps, common practice…?
I’ve always found it a complete pain to debug scene Luup code:
[ul][li]into the scene editor; [/li]
[li]make changes; [/li]
[li]save them; [/li]
[li]reload; [/li]
[li]wait; [/li]
[li]examine logs/variables; [/li]
[li]go round again… [/li][/ul]
…the biggest pain being the wait for reload - but what else to do?
The answer, of course, is to modify code on the fly without a reload.
Question: How to do that?
Answer: Put the code in a simple-to-access shared place.
Question: Where is that?
Answer: “[tt]Startup Lua[/tt]”.
So, for example, in my [tt]Startup Lua[/tt] I define:
akbooer = {} -- (let's ignore the deeper philosophical possibilities of the statement)
In my [tt]scene Luup code[/tt], a simple one-liner:
akbooer.test() --- possibly with some useful parameters from the local environment
Then, whenever I like, I can create any definition of [tt]akbooer.test[/tt] in [tt]Test Luup Code[/tt]:
function akbooer.test()
-- do interesting things here
end
and, magically, any subsequent activation of the scene with the call to this function runs the new definition (which, of course, can now be deleted here because the code is now pointed to by the global.) No reload, no waiting. I can change the function definition anytime I like.
In fact, rather than just using this method for debugging, I’m leaning towards using it as a standard approach for all scene Luup.
Now, the acid test - Am I:
[ol][li]rather behind the curve in realizing this?[/li]
[li]horribly mistaken, and there is a very good reason not to do this?[/li]
[li]completely missing some obvious alternative?[/li][/ol]
I await the judgement of those older and wiser (or, indeed, younger and less foolish) in the Vera / Luup / Lua school of hard knocks.