[1.1.107] Game not throwing an error when adding functions in global table
Posted: Thu Jun 13, 2024 2:21 am
Hello there,
In this page of the LUA API docs, it is said that "Functions are not allowed in global and will throw an error when saving.", however if you add a function in the global table (for example with this command "/c global.foo = function() end") the function will be added in the global function and will not be conserved through save/load cycle but it will only log a warning. This is really confusing because it is not what the docs says. Although I don't know which one is better between adding an error or modifying the docs.
Also I'm quite curious why it is impossible to add functions to the global table? I would imagine it has a link with the fact that the load function doesn't work with binary chunks but it doesn't help me much to understand.
The following log file is me:
- creating a new save
- running "/c global.foo = function() end"
- running "/c log(type(global.foo))"
- saving and reloading the save
- running "/c log(type(global.foo))"
In this page of the LUA API docs, it is said that "Functions are not allowed in global and will throw an error when saving.", however if you add a function in the global table (for example with this command "/c global.foo = function() end") the function will be added in the global function and will not be conserved through save/load cycle but it will only log a warning. This is really confusing because it is not what the docs says. Although I don't know which one is better between adding an error or modifying the docs.
Also I'm quite curious why it is impossible to add functions to the global table? I would imagine it has a link with the fact that the load function doesn't work with binary chunks but it doesn't help me much to understand.
The following log file is me:
- creating a new save
- running "/c global.foo = function() end"
- running "/c log(type(global.foo))"
- saving and reloading the save
- running "/c log(type(global.foo))"