Script auto exection is really a trouble design

User avatar
Posts: 964
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Script auto exection is really a trouble design

Post by SlySven »

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:

Code: Select all

echo("Hello World!")
this gets converted internally to:

Code: Select all

function alias42()
echo("Hello World!")
which is what is run (if non-empty) for that alias when it is used... :geek:

Post Reply