Detecting Code Reload?

FocusedWolfFocusedWolf Join Date: 2005-01-09 Member: 34258Members
Does anyone have any suggestions for a way to detect a "Recreating class 'className'" event, which occurs when you save changes to a lua file while ns2 is running.

Here's <a href="http://pastebin.com/rv2fQyCK" target="_blank">code</a> for how i'm dealing with this currently.

Comments

  • MaxMax Technical Director, Unknown Worlds Entertainment Join Date: 2002-03-15 Member: 318Super Administrators, Retired Developer, NS1 Playtester, Forum Moderators, NS2 Developer, Constellation, Subnautica Developer, Pistachionauts, Future Perfect Developer
    If you want to perform some specific action when a file is reloaded, you can just add something like this to your file:
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->local function OnReload()
      // Do whatever
    end
    OnReload()<!--c2--></div><!--ec2-->
  • FocusedWolfFocusedWolf Join Date: 2005-01-09 Member: 34258Members
    edited September 2011
    <strike>Ahh ok got it working.</strike>

    Warning to people, reloading from file changes (hotloading of lua files) can be hit or miss depending on what you're doing (usually though i think it's possible to get it working to the point of being good enough to try your changes without needing to restart NS2.... I have a way that sort of works for my mod... it's kind of complicated (no it's not what i show in post #1), so let me know if your desperate enough to want it... it's not perfect).

    Here's an advanced example where, to put it bluntly, Max's suggestion will not work: <a href="http://www.gamefront.com/files/service/thankyou?id=20679356" target="_blank">http://www.gamefront.com/files/service/thankyou?id=20679356</a>

    An example of were you can get away with no "reload" code (just a reload procedure) would be if you modding something like GUIMarineHUD.lua (marine user interface that shows when you join the marine team). When doing changes which affects this, the game will spew errors until you rr to the readyroom and j1. What's happening is the class is being destructed and recreated (think of it as manual reload of hotloaded class).
Sign In or Register to comment.