panraven Grandmaster Cheater
Reputation: 62
Joined: 01 Oct 2008 Posts: 958
|
Posted: Sun Aug 21, 2022 9:50 am Post subject: |
|
|
A helper function
| Code: |
local function indirect(prop)
return function (Object)
local delegated = Object[prop]
if not delegated then return nil,'no '..prop end
return setmetatable({},{
__index = function(me, key)
local r = Object[key]
if r~=nil then return r else return delegated[key]end
end,
__newindex = Object
})
end
end
-- test
local o = {a=1,b=2,entity={ c='hello'}}
local x = indirect'entity'(o)
x.XXX = 123
for k in ('XXX/a/b/c/entity'):gmatch'[_%a][_%w]*' do
print(string.format("key=%10s , o[key]=%30s, x[key]=%30s",k,o[k],x[k]))
end
|
You operate on the returned object instead on the original (player) directly. _________________
- Retarded. |
|