Does anybody know a way to circumvent the lua limit? I just reached it I’ve lowered the amount of files I use to fix it temporarily but that is only short term.
No, except for merging files.
GMod has several hard limitations, and this is one of them. Your best bet is combining files if they’re at all similar. Mind if I ask what your project is?
You could put your Lua files in the data folder then runstring file.read
Not sure if that’d work though.
I run a TTT server, one major cause is that I have PointShop with these masks that take up a lua file each (I have a lot). I’m gonna look into a way to maybe have one file for all the masks.
[editline]17th May 2014[/editline]
What is the reason for a hard coded lua limit in the first place anyways?
You could rewrite Pointshop’s item loading to instead have a function to register each item.
like PS:RegisterItem( id, item )
Well one probably is so people don’t just make files for one function.
Then there’s performance stuff like the auto lua refresher and maybe some general limits with memory.
Also all sorts with problems with how gmod caches clientside files. (You know calulating endless crc hashes, compressing/decompressing them…)
But tbh if you are hitting the file limit with items, you should probably rethink if they are worth it.
If you send me thousands of lua files and I’m stuck at loading for too long, I might as well play on another server that doesn’t have that many items I’m never going to use anyway.
Generally the files can be merged together and if the content of each file is inside its own ‘do’ block then they each get their own scope, exactly the same as if they were in their own files. This works fine in theory, but if you have addons that rely on files in being specific locations, they need to be worked around.
These two chunks should function the same, but 1 file compared to 5 (or any amount of) files.
[lua]–1 file calling the includes, plus 4 included files = 5 files total
–1 file, with multiple do blocks
– paste content of networking.lua
– paste content of playermeta.lua
– paste content of shop.lua
– paste content of thirdperson.lua
How many files is the limit?
2048 if I recall correctly.