Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function lock( t )
- t.__locked = true
- return setmetatable( {}, {
- __index = t,
- __newindex = function( )
- error( "attempt to modify read only table", 2 )
- end,
- __metatable = false,
- })
- end
- local _rawset = _G.rawset
- rawset = function( t, k, v, password )
- if t.__locked then
- error( "attempt to modify read only table", 2 )
- else--#change to else
- return _rawset( t, k, v )
- end
- end
- _G.rawset = rawset
- local t = { "hello" }
- t = lock( t )
- print( t.__locked )
- t.__locked = false --#error!
- print(t.__locked )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement