Using Class_ReplaceMethod

ChaosXBeingChaosXBeing Join Date: 2012-10-12 Member: 162114Members
<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?

Comments

  • MotigMotig Join Date: 2008-10-23 Member: 65281Members
    edited November 2012
    You have to include/load the file that holds the function you're trying to use:

    <i>Script.Load("lua/Class.lua")</i>

    This will allow you to use Class_ReplaceMethod()
  • ChaosXBeingChaosXBeing Join Date: 2012-10-12 Member: 162114Members
    <!--quoteo(post=2013530:date=Nov 6 2012, 09:34 PM:name=Motig)--><div class='quotetop'>QUOTE (Motig @ Nov 6 2012, 09:34 PM) <a href="index.php?act=findpost&pid=2013530"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->You have to include/load the file that holds the function you're trying to use:

    <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.
Sign In or Register to comment.