Open EstevanTH opened 9 years ago
Use CompileFile. The decompressed contents of the Lua files don't actually exist anywhere on the file system so I don't see fixing this as necessary.
That is useful! Thank you. :smiley: Anyway it's too late, I chose to use include() when the file cannot be read properly, but I'm not sure that it will work if startup includes limit is over.
You're thinking of the CS Lua file limit? That limit is only for the amount of files which can be sent to clients by the server. Even with file.Read, include or CompileFile you'll be limited by the limit.
One issue with your file.Read system would be people (and people do abuse these systems) using it to get past sv_allowcslua.
Nope, the problem that breaks includes (of internal stuff as well) after a given number of Lua files included. This is called the "too many addons" bug.
EDIT: Also, thank you for the info, I need to fix that finally...
Just hit this problem myself. Luckily I can network the files pretty easily.
Done... but file.Read would be a lot faster.
So yeah, we've got CompileString, but what when i want to read file contents instead of compiling it into lua function?
You can't, devs apparently don't want clients reading server's client code; (pretty sure there's workaround for this anyway though).
It's very simple outside of lua, secondly, if file.Exists returns true for these files, does the file actually exist or not?
I mean, if nobody requested it in like 10 years, probably nobody wants it.
So Rubat, it looks like someone did, huh? (For context: #5719)
Hello robotboy and co,
I found a problem when trying to read Lua files. If the Lua file does not exist clientside (in general because of addon not mounted), the file can be found but it fails when attempting to read.
Here is my code to load vehicles Lua files with the minimum of problems regarding the startup Lua includes limit. It delays the load of Lua files and safely run every Lua script.
For people who have my addon mounted (SVN, Workshop or probably Workshop sent by the server), the Lua files exist clientside so the Lua files can be read. But for any Lua file that is sent by the server with no matching Lua file mounted clientside (not subscribed to the SVN and no usage of Workshop), then the Lua file cannot be read.