Modding newbie problems
<div class="IPBDescription">what am I doing wrong?</div>Decided to try to learn how to do some basic modding for ns2. First step, just wanted to mess with the minimap colors. So I open the ns2 project in decoda, get to the minimap code (GUIMinimap.lua), create a local game, find this line:
GUIMinimap.kTeamColors[kMinimapBlipTeam.Friendly] = Color(0, 1, 0, 1)
Change it to
GUIMinimap.kTeamColors[kMinimapBlipTeam.Friendly] = Color(0, 1, 1, 1)
(just wanting to confirm that Color takes R, G, B, Alpha), save the file, alt-tab back into game, and....problems. I don't see any color change, and some of my GUI has frozen (arrow indicating player's position won't animate, alien vision blips not updating, etc.)
Is there something special I need to do to make the dynamic loading of altered LUA files work?
GUIMinimap.kTeamColors[kMinimapBlipTeam.Friendly] = Color(0, 1, 0, 1)
Change it to
GUIMinimap.kTeamColors[kMinimapBlipTeam.Friendly] = Color(0, 1, 1, 1)
(just wanting to confirm that Color takes R, G, B, Alpha), save the file, alt-tab back into game, and....problems. I don't see any color change, and some of my GUI has frozen (arrow indicating player's position won't animate, alien vision blips not updating, etc.)
Is there something special I need to do to make the dynamic loading of altered LUA files work?
Comments
So, the old instances of your HUD elements are not being uninitialized, which is why they are still on your screen. They are stuck because they are from before reloading the file and cannot be referenced by the game anymore. Whenever you change any HUD elements, go back to the readyroom before doing any changes (since there are no HUD elements in the RR apart from name tags on players). You should also start the game in windowed mode, otherwise you will have a few seconds to minutes of lag whenever you alt+tab back into the game because the local server has to "catch up" with what has happened in the meantime because it is in some sort of sleep mode when it is in the background and in full-screen mode.
If you make changes to server side files, you will unfortunately have to recreate the game 99% of the time because the server usually completely breaks when reinitializing one of the classes (e.g. error spam in console).
By the way, <b>never</b> change the original files. Always copy them to a new folder alongside ns2 with the same folder structure and use "-game foldername" on the shortcut to start the game with the modded files (<a href="https://pickhost.eu/images/0005/3950/Natural_Selection_2_Mod_Setup.jpg" target="_blank">this is what my setup looks like</a>). This way, if you accidently break something, you won't have to verify integrity and lose all of your changes in the process and you also have an overview of what files you've changed and which changes you've made. The only downside is that Decoda can be really confused and break stuff if you open two files with the same name in different folders, so don't do that. I personally use a text editor with syntax highlighting support for modding (most people use Notepad++, it's free) and have the NS2 project open in Decoda in the background when I want to search for something (the Find in Files function [Ctrl+Shift+F] is incredibly useful).
If you need any more help or just didn't understand anything of what I just said, <a href="http://steamcommunity.com/id/dghelneshi" target="_blank">hit me up on Steam</a>.
Is there any way to know before hand if a particular change is going to be dynamic reloading compatible or not other than just trying it and seeing if anything breaks?
Is there any way to directly call certain functions from the console? For example I can see that GUIMinimap has a very obvious Initialize and Uninitialize functions, is there any way to just open the console and tell it to run GUIMinimap:Uninitialize then GUIMinimap:Initialize (assuming that if this were possible it would fix my problem)?
local gGUIManager = nil
Its the variable that holds the single created instance of GUIManager that keeps track of and updates frames. Whenever a hot reload happens gGUIManager is reset to nil which causes GetGUIManager() to create new instance of GUIManager that knows nothing about all the existing frames created
If you remove local from the variable declaration it should fix frames getting stuck
<!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->Is there any way to directly call certain functions from the console? For example I can see that GUIMinimap has a very obvious Initialize and Uninitialize functions, is there any way to just open the console and tell it to run GUIMinimap:Uninitialize then GUIMinimap:Initialize (assuming that if this were possible it would fix my problem)?<!--QuoteEnd--></div><!--QuoteEEnd-->
This snippet of code should create console command to recreate the minimap I haven't tested but in theory it should work
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Event.Hook("Console_reloadmap", function()
GetGUIManager():DestroyGUIScriptSingle("GUIMinimap")
local player = Client.GetLocalPlayer()
player.minimapScript = GetGUIManager():CreateGUIScriptSingle("GUIMinimap")
end)<!--c2--></div><!--ec2-->