Team Spartan Cookies & Milk Forums

Full Version: Global Functions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Not that i'm one to complain when something is changed, this one kinda ruins the whole vanilla lua experience, blocking the ability to override any of the global functions basically ruins a lot of my scripts, I'm personally fine with functions like error, and steamid. Blocking all functions is kinda excessive.
00:01 - тѕсм.Red T-he Blue Color™: just agree with me lol
00:02 - тѕсм.Obi-Swag Kenobi: oh ok

on a serious note, I have no clue why i'm here and Red dragged me here
Ignore my bullshittery on this thread
I don't do anything as advanced as red so I don't have any need to override global functions, but I agree that it's kind of excessive to block everything.
I was the one that reported the issue because it seemed like a security breach to me, and I have to say that I agree with Red on the point that it is exagerrated to block every modification on vanilla functions. I personally think that they are some better way to fix this problem without handicap some people and their creations.

For exemple, this fix would have been great if it was applied only to libs and files that has been called through require().
Even better if there was a little checkbox to allow people or not to require()/include() this file.
Or maybe just block modifications on some important functions like ConfusedteamID(), ents.owner() or even error(). (and some other that gives us the path of the main file)
Agreed and i m not saying it because is threat me.
It was implemented to stop loading execute files as libs and then using the overridden globals to exploit the code, my suggestion is to protect starfall.getMainFile() and make the method known to all.
(10-08-2017, 10:15 PM)T-19 Wrote: [ -> ]It was implemented to stop loading execute files as libs and then using the overridden globals to exploit the code, my suggestion is to protect starfall.getMainFile() and make the method known to all.

It seems like the best solution i can't think of anyone who would have an actual code need to override starfall.getMainFile
Plus a simple check on a starfall with starfall.getMainFile() allows us to stop any further modifications. Seems like the best option to me.
I think making _G unmodifiable does more harm than good, especially given that you can deny certain people access to your scripts using access privileges.
Not to mention that there were numerous ways to detect when the environment has been modified in a non-subtle way.

EDIT: I'd say making a function isMainFile() which resides in the global namespace would be more practical to use. Or even worse, make it a pre-processor directive.
EDIT2: Actually, the latter might be a nice extension to the @class directive, after the type you can specify that this file must be the main file.
You should not have a need to ever modify the behaviour of default functions. While it is possible in Lua by default, it is generally discouraged. A developer should never have to worry that a standard function may act differently.

If you have behaviour you want to use then you create your own functions. This is still possible.

Making the environment only protect certain functions is even worse as it's even less obvious to a developer which ones they can and can't change (even though they shouldn't be changing any at all).

What are the use-cases that people have for overriding default functions?
Pages: 1 2