Replace function rather than entire file?

Pulseczar

Chieftain
Joined
Oct 30, 2010
Messages
12
I want to modify some of the core code, but it would be more modular for me to just replace a function rather than to replace an entire file, that way I could retain compatibility with any mod that also alters the file, as long as they don't alter the function that I alter.

Is there a way to just replace a Lua function?
 
have you tried just writing your own function that uses the same name? i think it should replace it seeing how its the same name and your mod loads after, ie overwrites it. as long as the function being replaced isnt being added into an event anyway

but i'm really new to lua so i don't know for sure. for example, i'm still trying to find lua equivalents of perl's next, redo, last
 
Yeah, you would think you could do that, but all I've seen people doing in Mod Hub is replacing entire files, even though they only touched one or two of the functions in the file. Gave me the impression that it probably can't be done, or no one knows how yet. The lack of response to this thread also implies to me that no one knows of a way to do it. I will try what you suggested.
 
I think that the problem is that all mods are confined into their own threads environment. So it won't help even if you create a function with the same name as in core-files, because the core-file will only call the functions created in their own thread. That's why people are forced to replace the entire core-files for any changes to them. :(
 
I tried replacing print(). That caused lockup on game start.

I've also noticed that if you include the same lua file both thru a database update of the InGame.xml as well as an InGameUIAddin under the content tab, it locks up the same way. So while there are instances where you can attempt to redefine the same function, it appears to kill the game.
 
Back
Top Bottom