Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local forbidden = {"unpack", "5"}
- local contains = function(array, search)
- for index, value in pairs(array) do
- print(index, value)
- if value == search then
- return true
- end
- end
- return false
- end
- setfenv(1, setmetatable({print = print}, {
- __newindex = function(self, key, value)
- if contains(forbidden, value) then
- print("Sandbox: attempt to set " .. key .. " to " .. value .. ", a forbidden " .. type(value) .. "!")
- return rawset(self, key, nil)
- else
- return rawset(self, key, value)
- end
- end,
- __index = function(self, index)
- end
- }))
- x = "5" --> Sandbox: attempt to set x to 5 (a forbidden value)
- print(x) --> nil
Advertisement
Add Comment
Please, Sign In to add comment