What is the standard, modern way to create a mod in Build 257

DarkOmenDarkOmen Join Date: 2002-11-05 Member: 7148Members
Hello, everyone!

I see many resources that describe methods of hooking up LUA mods in NS2, but what is the proper, modern method of creating a mod that includes code changes as of build 257? Everything seems to date back to build 147 or some such and hasn't been updated since.

Can someone link me to the definitive build 257 starting point? I'm sorry for making this thread, but nothing seems particularly intuitive to me.

Thanks a lot!

Comments

  • McGlaspieMcGlaspie www.team156.com Join Date: 2010-07-26 Member: 73044Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Squad Five Gold, Reinforced - Onos, WC 2013 - Gold, Subnautica Playtester
    This is something that really needs, clear, and concise explanations. Not too mention the Whys and Why-Nots.

    I recommend taking a look at:
    http://forums.unknownworlds.com/discussion/128106/how-to-make-a-mod-for-natural-selection-2#latest

    This will at least get you pointed in the right direction. Yes, this does it the "Old Way", but in practice it's not the "Wrong Way" to go about it. Frankly, there is no wrong way. It's just a matter of picking the trade-offs you're comfortable with.

    In some ways, the "modern" (if you can call it that) way is to use Sewlek's mod framework approach, see this workshop item:
    http://steamcommunity.com/sharedfiles/filedetails/?id=137123467

  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    There is no "build 257 starting point". You use the code as reference and use Sewlek's framework.
    Simply overriding files by adding stuff to default code and put that in your mod works too. Some things you have to do that in where you can't hook into functions, like most GUI files.
  • DarkOmenDarkOmen Join Date: 2002-11-05 Member: 7148Members
    Thanks for the insight! Alright, so I've gone along with copying all of ns2/lua into mymod/lua and I'll just modify everything from there. Now, consistency checking is preventing me from running a local server, so I've modified ConsistencyConfig.json so that it ignores *.* and checks nothing. Success!

    So hackish, though.
  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    edited October 2013
    No no no. You don't copy ns2/lua into your mod. If you do need to override a file, you copy only that file, in the correct file structure. So if you want to modify GUIMainMenu.Lua, you copy it into your mods lua/menu/ directory that you create. You also don't want a game_setup.xml if you are doing that. Proper method is to use hooks like Sewlek does. Copying all of ns2/lua will break your mod every update, and will override other things by accident. Individual files are less likely to break.
  • GhoulofGSG9GhoulofGSG9 Join Date: 2013-03-31 Member: 184566Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Reinforced - Supporter, WC 2013 - Supporter, Pistachionauts
    edited October 2013
    Before you do so, what exactly do you want to do?

    Because instead of overriding files you should use hooks and the entry system. game_setup.xml should only be used for new gamemodes changing the game in a huge way (like the faded, mvm, combat, xenoswarm)

    Overriding game files is not the optimal way to go and should only be used if there is no other way to do it.
  • DarkOmenDarkOmen Join Date: 2002-11-05 Member: 7148Members
    edited October 2013
    I'd call it a game mode: I want to try to "improve" the commander UI and behaviour. Ideally, it would register as a new game mode like Xenoswarm or Sewlek's Test Mod.

    Thanks for stopping me/walking me through this, btw.
  • VitdomVitdom Join Date: 2012-04-30 Member: 151345Members, Reinforced - Supporter, Reinforced - Silver, Reinforced - Gold, Reinforced - Diamond, Reinforced - Shadow, WC 2013 - Shadow
    edited October 2013
    You can easily create hook-based add-ons and in a lot of cases use the ReplaceClassFunction features.

    Just put some code in a myCode.entry to link to a .lua file and put it in the lua/entry/ and lua/ folder respectively. It should load automatically.

    http://wiki.unknownworlds.com/ns2/Modding_Framework

    Example program:
    ./lua/entry/HPK.entry
    modEntry = [[Server: lua/HPK.lua, Priority: 5]]
    
    ./lua/HPK.lua
    local function HPK_initPingCheck(client)
    	HPK_maxPing = Server.GetConfigSetting("max_ping")
    	if HPK_maxPing and HPK_maxPing ~= 0 and not client:GetIsVirtual() then
    		local startTime = Shared.GetTime() + 30
    		table.insert(HPK_queue, {client:GetId(), 0, startTime, startTime})
    	end
    end
    Event.Hook("ClientConnect", HPK_initPingCheck)
    
    local function HPK_setMaxPing(client, limit)
    	if limit then
    		HPK_maxPing = tonumber(limit)
    		Server.SetConfigSetting("max_ping", HPK_maxPing)
    		ServerAdminPrint(client, "sv_maxping " .. limit)
    	else
    		ServerAdminPrint(client, "sv_maxping " .. HPK_maxPing)
    	end
    end
    CreateServerAdminCommand("Console_sv_maxping", HPK_setMaxPing, "<limit>")
    
    local function HPK_checkPings()
    -- Some code...
    end
    Event.Hook("UpdateServer", HPK_checkPings)
    
  • DarkOmenDarkOmen Join Date: 2002-11-05 Member: 7148Members
    I did not know about that wiki page, and never quite understood the "guts" of Class_Reload(). Nor did I know about Event.Hook(), so thank you Vitdom!
Sign In or Register to comment.