lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


https://github.com/SoniEx2/Stuff/blob/master/lua/Sandbox.lua

In C you can basically make multiple Lua states that are independent from eachother: they have their own globals (including global metatables, like the string metatable etc), their own registry? (idk), etc. This 250 LOC beast is slow as fuck and lets you do something similar enough that you can use it for sandboxing.

Why can't we get a way to make independent Lua states from Lua, anyway? (or rather with isolated registry and global metatables - this means the GC would be shared between them, thus allowing objects to be shared between them, but they wouldn't share the same global metatables or the same globals table) It would open up great possibilities! Not just sandboxing, but modularization and local monkeypatching (e.g. make your Lua module open a Lua state, then monkeypatch its string metatable etc so you can write your fancy monkeypatched code without breaking the code of ppl who use your module)
-- 
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.