VE Lua Documentation

Press F to search!

__luaBindNewindex

Definition


-- @/lua/common/luaBinding.lua:84

function __luaBindNewindex(t, k, v)
  local mt = getmetatable(t)
  --log('E', '', '__newindex invoked on ' .. tostring(mt.___type))
  local origsetters = rawget(mt, 2) -- 2 = setters
  local setFunc = rawget(origsetters, k)
  if setFunc ~= nil then
    setFunc(t, v)
    return
  end

  while true do
    mt = rawget(mt, 3) -- 3 = super
    if not mt then
      --log('E', '', string.format("property '%s.%s' is not found or not writable: %s", getmetatable(t).___type, k, debug.traceback()))
      return
    end
    local setters = rawget(mt, 2) -- 2 = setters
    if setters then
      local setFunc = rawget(setters, k)
      if type(setFunc) == 'function' then
        rawset(origsetters, k, setFunc)
        setFunc(t, v)
        return
      end
    end
  end
end

Callers