Originally Posted by Banknorris
Not sure if I am understanding correctly what you are saying but upvaluing will indeed make your hook on global functions not run if the upvalue is set before the hooking. When you hook you create another function, but the upvalued pointer will still point to the old version (pre hook). But maybe you are talking about something else.
|
Except you are not hooking a function call, but a call for it's memory pointer's reference.
You can try it yourself:
Lua Code:
hooksecurefunc("SetCVar", function(name, value)
if name == "Sound_EnableMusic" then
print(name, value)
end
end)
local SetCVar = SetCVar
SetCVar("Sound_EnableMusic", 1)
You can do this in the other way around, it won't change a thing:
Lua Code:
local SetCVar = SetCVar
hooksecurefunc("SetCVar", function(name, value)
if name == "Sound_EnableMusic" then
print(name, value)
end
end)
_G.SetCVar("Sound_EnableMusic", 1)