• Referencing a function and running code on it's reference without overwriting it?
    2 replies, posted
I am working with another lua library, and it works a little like gmod Lua, in that I could reference certain variables in this way: function stuff:doathing(a) newa = a end I have been using that method to grab variables passed in the functions, because the code is compiled and I cant see how they do it in the source. The problem is that that overwrites the original function and breaks the game, any idea how I can get the variable from the args without overwritin it?
doathingbackup = stuff:doathing function stuff:doathing(a) doathingbackup(a) newa = a end But, I think there might be an issue with hidden "self" arguments being passed. Play around with it.
[QUOTE=Insomnia Array;34127300]doathingbackup = stuff:doathing function stuff:doathing(a) doathingbackup(a) newa = a end But, I think there might be an issue with hidden "self" arguments being passed. Play around with it.[/QUOTE] It's the right way to do it, but your function doesn't work. [lua] local oldDoSomething = stuff.DoSomething function stuff:DoSomething(a) newa = a return oldDoSomething(self, a) end [/lua]
Sorry, you need to Log In to post a reply to this thread.