Trying to replace PlayingTeam:AddTeamResources with custom logic. But it's not working.
Hello, I'm trying to make a mod for NS2 and I'm having a fair bit of difficulty hooking into this function. I'm not entirely sure what I'm doing wrong.
Here's the code for my ModShared.lua as well as the code for my ModPlayingTeam.lua (which only replaces one function, well is trying to). My logic isn't complete naturally but I'm just trying to test it and get it working before moving forward. Modifying the function in the original file (well a duplicate file with PlayingTeam.lua as the name so ns2 loads it) works, so the logic itself works but I can't seem to hook into it without replacing the entire original file.
ModShared.lua:
ModPlayingTeam.lua
What am I doing wrong?
Here's the code for my ModShared.lua as well as the code for my ModPlayingTeam.lua (which only replaces one function, well is trying to). My logic isn't complete naturally but I'm just trying to test it and get it working before moving forward. Modifying the function in the original file (well a duplicate file with PlayingTeam.lua as the name so ns2 loads it) works, so the logic itself works but I can't seem to hook into it without replacing the entire original file.
ModShared.lua:
if Server then Script.Load("lua/Server.lua") elseif Client then Script.Load("lua/Client.lua") elseif Predict then Script.Load("lua/Predict.lua") end Script.Load("lua/Class.lua") -- Load mod files here. Script.Load("lua/UberShotgun.lua") if Server then Script.Load("lua/ModPlayingTeam.lua") end
ModPlayingTeam.lua
function PlayingTeam:AddTeamResources(amount, isIncome) if amount > 0 and isIncome then self.totalTeamResourcesCollected = self.totalTeamResourcesCollected + amount end self:SetTeamResources(self.teamResources + amount * 2) end
What am I doing wrong?
Comments
You're statement "You will also need to be sure that anything using PlayingTeam class is loading your file and not vanilla." I'm not too sure I understand what you mean by that.