lewisclark / glua-steal

Retrieves client-sided Lua files from Garry's Mod game servers
GNU General Public License v3.0
151 stars 15 forks source link

Is Overriding Lua Files Possible? #60

Closed NobleFalcon closed 6 months ago

NobleFalcon commented 9 months ago

I'm interested in knowing whether it's possible to override existing Lua files while maintaining full access to the source file's methods and networking. I need to alter the behavior of the existing lua file without losing their inherent network communication abilities and method implementations.

For example net.ReadUInt(16) or local obj = OBJ.RANK will no longer be accessible if I use:

if (gluasteal.SCRIPT:match("cl_ranks")) then
    gluasteal.include("cl_ranks.lua")
    return false
end
lewisclark commented 9 months ago

You can store the contents of a file at execution time using the gluasteal.SOURCE variable - from there you can programmatically pull out the code you require and execute it using RunString. I would prefer to achieve the desired result by overriding global functions it calls or copying all code required into a new replacement file to be executed instead.