[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Capturing Lua variable as a string
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 1 Oct 2007 08:18:46 -0300
> The same is repeated for all variables. Instead I want the string
> equivalent of variables DeviceParam1, DeviceParam2, DeviceParam3
> handled internally by Lua and assigned to NAME property.
Set up a proxy for _G and set a __newindex for the proxy that does that.
Something like this:
local function set(t,k,v)
print("SET",k,v,type(v))
if type(v)=="table" then v.NAME=k end
rawset(t,k,v)
end
setmetatable(getfenv(),{__index=_G,__newindex=set})