Using Class_ReplaceMethod
ChaosXBeing
Join Date: 2012-10-12 Member: 162114Members
in Modding
<div class="IPBDescription">Class_ReplaceMethod is a nil?</div>The title pretty much explains it all. In the first ten minutes of coding my mod I hit a brick wall, where I've stayed for a few days now. I've already tried and exhausted every idea I could come up with, so I decided to turn to the NS2 modding community once again.
The code that's giving me an issue is just supposed to make Cysts provide line-of-site while connected to the hive.
<b>InfestationMod_Cyst.lua</b>
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Script.Load("lua/Cyst.lua")
local originalOverrideCheckVision = Class_ReplaceMethod("Cyst", "OverrideCheckVision", function()
if Server then
return self:GetIsActuallyConnected()
else
return self:GetIsConnected()
end
end)<!--c2--></div><!--ec2-->
<b>InfestationMod_Client.lua</b>
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Script.Load("lua/Client.lua")
Script.Load("lua/InfestationMod_Cyst.lua")
Event.Hook("UpdateClient", OnUpdateClient)<!--c2--></div><!--ec2-->
That's it. And yet, no matter what I do, I always get the same error.
<!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->Attempt to call global 'Class_ReplaceMethod' (a nil value)<!--QuoteEnd--></div><!--QuoteEEnd-->
I'd provide the actual console log, but I searched the entire ns2 folder for a .log file and apparently there isn't one.
Does anyone have any idea what might be causing this?
The code that's giving me an issue is just supposed to make Cysts provide line-of-site while connected to the hive.
<b>InfestationMod_Cyst.lua</b>
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Script.Load("lua/Cyst.lua")
local originalOverrideCheckVision = Class_ReplaceMethod("Cyst", "OverrideCheckVision", function()
if Server then
return self:GetIsActuallyConnected()
else
return self:GetIsConnected()
end
end)<!--c2--></div><!--ec2-->
<b>InfestationMod_Client.lua</b>
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Script.Load("lua/Client.lua")
Script.Load("lua/InfestationMod_Cyst.lua")
Event.Hook("UpdateClient", OnUpdateClient)<!--c2--></div><!--ec2-->
That's it. And yet, no matter what I do, I always get the same error.
<!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->Attempt to call global 'Class_ReplaceMethod' (a nil value)<!--QuoteEnd--></div><!--QuoteEEnd-->
I'd provide the actual console log, but I searched the entire ns2 folder for a .log file and apparently there isn't one.
Does anyone have any idea what might be causing this?
Comments
<i>Script.Load("lua/Class.lua")</i>
This will allow you to use Class_ReplaceMethod()
<i>Script.Load("lua/Class.lua")</i>
This will allow you to use Class_ReplaceMethod()<!--QuoteEnd--></div><!--QuoteEEnd-->
*Facepalm*
Yes. That might help. Much obliged, Motig. I didn't know it needed another lua file to be loaded. (Though I had a feeling it'd be something small. The irritating ones always are.)
Thanks also to Double_hex who, once again, was quick to message me when he saw this thread and point out my problem as well.