How do you develop a mod? Best practice?

simple_simple_ Join Date: 2013-09-10 Member: 188102Members
So yeah how do you do it?
I don't mean the stuff from the tutorial, but things like:
How do you find out how things work under the hood?
How do you test you code in a timely manner?

As an example:
At the moment I'm trying to figure out, if a player/client knows in which hot(key)group he is or if the client doen't know, how to tell him.
The api I found in the wiki is not really comprehensive.
So at the moment, I take the bits and pieces from the web and try stuff out. But trying my code means I have to start the game and load a map, which can take up to a few minutes.
When I have a typo I have to starte again, waiting 3 minutes, because lua is a dynamic language.

Do you guys have a few tips, how to get the information that I need, and how do speed up my development process?
Is three a way to (re)load a lua script ingame?

Thanks!

Comments

  • Racer1Racer1 Join Date: 2002-11-22 Member: 9615Members
    You can hotload lua changes in-game, so you don't need to restart. I forget how.
  • 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 September 2013
    Ok, so i'll tell you a bit my workflow:

    1. Think about what i want to do and which UWE NS2 classes i will need to change.
    2. Look those classes up in ns2docs (i attached the current version)
    3. Write the code
    4. Test the new stuff at a local server with bots. Fun fact: i played over 200 bot rounds the last few weeks to debug ns2stats

    About those typo errors , mods are loaded before precacheing beginns, so watch the console while loading if there is a error type run "disconnect" to stop loading. Reload ingame use "sv_changelevel ns2_veil" . Mod files are reloaded with mapchange.

    And about your idea i think you have to create something like this: if commander creates a hotkeygroup, sent a networkmessage to server which includes groupkey + groupunits, then the server has to sent a networkmessage to the grouped clients to inform them that they have been grouped ...
  • simple_simple_ Join Date: 2013-09-10 Member: 188102Members
    edited September 2013
    Thanks for the docs! They can be build with the tool, I guess?
    Thanks for the disconnect tipp^^

    So sv_changelevel doesn't do anything ingame, do I have to do something else before?
    But if I use a mapchange, then I still have to wait through loading and prechaching, do I not?

    So you are on a first name basis with the bots?
    :P
  • 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 September 2013
    Oh sry personally im running shine on my testservers so i can use the chatcommand !map and sh_luarun. Command for mapchange at vanilla is just "changemap". And another tipp i have for you: don't trust builder.exe always check the output folder before you publish.
  • SewlekSewlek The programmer previously known as Schimmel Join Date: 2003-05-13 Member: 16247Members, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Developer
    i suggest making a tiny test map. something like a simply ready room (you dont need team portals even, and two tech points, res nodes, with as little textures as possible. hotloading lua doesnt work really, so dont rely on that. i simply did "bind F5 map <testmapname>" as alternative, with a fast to load test map
  • simple_simple_ Join Date: 2013-09-10 Member: 188102Members
    Sewlek wrote: »
    i suggest making a tiny test map. something like a simply ready room (you dont need team portals even, and two tech points, res nodes, with as little textures as possible. hotloading lua doesnt work really, so dont rely on that. i simply did "bind F5 map <testmapname>" as alternative, with a fast to load test map
    Sound like a plan...is making a map complex? Not really my expertise :)

  • 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 September 2013
    Sewlek wrote: »
    i suggest making a tiny test map. something like a simply ready room (you dont need team portals even, and two tech points, res nodes, with as little textures as possible. hotloading lua doesnt work really, so dont rely on that. i simply did "bind F5 map <testmapname>" as alternative, with a fast to load test map

    I did this like exactly, except my key is F7, and the map is from watermod. Loads super quick, because yeah don't trust hotloading, because it doesn't work very well.

    https://www.dropbox.com/s/gmhghc18k3mys2r/ns2_watertest.level
  • MCMLXXXIVMCMLXXXIV Join Date: 2010-04-14 Member: 71400Members
    My advice, on top of what's already been said, is to make sure to favour hooking before/after a vanilla NS2 function rather than overriding it, which saves you a ton of pain if the function you've overridden gets updated in some fundamental way in future. For best results, put your new code into new Mixins and load them in a post-hook on the OnCreate/OnInitialized like we do in Xenoswarm. Using Sewlek's mod framework will also save you a bag of time too.
  • 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 September 2013
    MCMLXXXIV wrote: »
    My advice, on top of what's already been said, is to make sure to favour hooking before/after a vanilla NS2 function rather than overriding it, which saves you a ton of pain if the function you've overridden gets updated in some fundamental way in future. For best results, put your new code into new Mixins and load them in a post-hook on the OnCreate/OnInitialized like we do in Xenoswarm. Using Sewlek's mod framework will also save you a bag of time too.

    If you don't want to write a new gamemode ala Combat you can also use Shine Core as Framework:
    https://github.com/Person8880/Shine/wiki/Developing-a-Shine-plugin
    https://github.com/Person8880/Shine/wiki/Hook-Library
    https://github.com/Person8880/Shine/wiki/Plugin-network-messages

    It allows you easily to create and manage Hooks,Netwokmessages, has a fail protection and many other things.

  • Ghosthree3Ghosthree3 Join Date: 2010-02-13 Member: 70557Members, Reinforced - Supporter
    edited September 2016
    Racer1 wrote: »
    You can hotload lua changes in-game, so you don't need to restart. I forget how.

    You put -hotload in the launch options (or in a shortcut, eg. "D:\Games\Steam\steamapps\common\natural selection 2\NS2.exe" -game "C:\Users\username\Downloads\Natural Selection 2\Mods\Hidden Spectator Mod\output" -hotload).

    If you do this though make sure that your "\AppData\Roaming\Natural Selection 2\ConsistencyConfig.json" doesn't block anything, because you'll get kicked out of the game the moment you change a file if it does.
  • simple_simple_ Join Date: 2013-09-10 Member: 188102Members
    Thanks guys, I will have a look at everything!

    Why isn't hotloading reliable?
  • 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 September 2013
    simple_ wrote: »
    Thanks guys, I will have a look at everything!

    Why isn't hotloading reliable?

    It has starnge memory leaks and produces errors you will never see if you load your mod normal. That is why most ppl don't use it.

  • 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
    If you're working with Decoda, SHIFT+CTRL+F is your best friend.
  • simple_simple_ Join Date: 2013-09-10 Member: 188102Members
    McGlaspie wrote: »
    If you're working with Decoda, SHIFT+CTRL+F is your best friend.
    What does Shift Ctrl F do?
    I usually use emacs. Does Decoda bring anything to the table, thats a reason to switch?
  • 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
    simple_ wrote: »
    McGlaspie wrote: »
    If you're working with Decoda, SHIFT+CTRL+F is your best friend.
    What does Shift Ctrl F do?
    I usually use emacs. Does Decoda bring anything to the table, thats a reason to switch?
    It's the search all files function. Every time you need a function from ns2 but have no plan where is is you load all ns2 lua files into decode and search for the function name. Also usefull for big projects.
Sign In or Register to comment.