Re: Script auto exection is really a trouble design
Posted: Fri May 15, 2020 5:08 am
Also the auto-execution is also necessary IIRC to ensure that the Lua code is good or buggy (and if the latter gets disabled and marked with a bug icon) so it cannot be entirely removed.
I suspect some difficulties may crop up for what one might call "direct" Lua code/scripts which do get executed each time this happens as opposed to the "indirect" stuff inside functions declared in the scripts which are only compiled...
As it happens, for all the other types of item for which Lua code can be entered, that code is invisibly wrapped up in a lua function (which currently offsets the line numbers in lua error messages by 1 IIRC) but the behaviour has to be different for the Script type item. For example the code for an alias with the ID number 42: this gets converted internally to:
which is what is run (if non-empty) for that alias when it is used...
I suspect some difficulties may crop up for what one might call "direct" Lua code/scripts which do get executed each time this happens as opposed to the "indirect" stuff inside functions declared in the scripts which are only compiled...
As it happens, for all the other types of item for which Lua code can be entered, that code is invisibly wrapped up in a lua function (which currently offsets the line numbers in lua error messages by 1 IIRC) but the behaviour has to be different for the Script type item. For example the code for an alias with the ID number 42:
Code: Select all
echo("Hello World!")
Code: Select all
function alias42()
echo("Hello World!")
end