How do you make your Lua scripting mods?

TooMuchFunTooMuchFun NunyaBiznizz Join Date: 2014-04-28 Member: 195653Members
I've got a pretty good handle on programming and scripting languages, but I've never completed a fully functional application. I've made experiments and things like that but never have I actually finished anything...

Anyways that is beside the point! I want to know how everyone else learned how to mod NS2. I would like to do a few things with it but I don't know where to begin like what files to change, how everything fits together to make the game work. For example if I wanted to make the flamethrower launch grenades where would I begin looking into that? I look at learning to use an applications code base like a map in a video game. You start in one part and venture off until most if not all of the map is complete. Am I right?

Comments

  • IronsoulIronsoul Join Date: 2011-03-12 Member: 86048Members
    Hey, how much time do you have available to look into this stuff? I'm starting on a path(FINALLY) to fully learn and document ns2 modding. Here's what I know so far:

    NS2 has no documentation for modding. Well it's got some but it really doesn't have anything as good as source, unity, unreal engine 4 etc. Generally we're expected to read the game code and learn from that, which in my opinion is both fine and terrible. Fine because even with documentation you'll have to do that anyway, terrible because it makes understanding how things are done all the more difficult.

    Either way, ns2 mods work by hooking in to a couple of other functions. What is hooking in? Dunno, how do you do it? Not sure yet, what does it achieve? It let's you add functionality on to an existing function. For example, you can modify a grenade launcher to fire a grenade that explodes into another grenade without having to replace the original grenade launcher code.

    If you've got some spare time, keep posting in this thread and share what you learn, I'll do the same.
  • TooMuchFunTooMuchFun NunyaBiznizz Join Date: 2014-04-28 Member: 195653Members
    Okay I will probably do that but right now (right now being <1 month before college resumes for me) I'm working on other projects. Perhaps I would be good at documenting the code for everyone because of my experience with programming/scripting. I found myself browsing the .lua files for NS2 today and reached the conclusion that reading Lua scripts and comprehending them is a helluva lot easier than another language such as C++ or Python. In fact I would recommend against learning C++ as a beginners language because its just that difficult for someone unaccustomed to programming computers! When I was just a teenager I wanted to make games and I thought learning C++ would be the way to go. I don't know why, I think I had some notion about C++ being the definitive game programming language. Fast forward about ten years and I'm just grasping the language. Life events and spending more time doing nothing productive (ie. gaming) stalled my progress for much of that time. Fortunately this summer I really have been practicing my skills and learning TONS. I switched my major to CS this summer too (my dream career honestly).

    I have some advice for all of you aspiring NS2 modders though: search engines are the best source of information about programming concepts and CS related stuff. Two notable websites that I use are: stackoverflow.com and daniweb.com . I prefer daniweb.com but stackoverflow isn't bad. I prefer it because 1. I got banned from SO.com because I asked "stupid" questions (my thoughts not theirs, when a website directs you on how to ask "good smart questions" the opposite end of that spectrum comes into question). SO.com is really for professionals anyhow. Daniweb is much more friendly!

    I you get an error; copy that text and pasted it into a search engine. There are bound to be tons of people with the exact same problem you have out there!

    Also, never ask anyone a question like "What is the BEST......?" for a given purpose or anything. Because that's a question asking for somebody else's opinion and you're bound to get a mixed bag of replies and a load of opinionated trash! C++ may not be a good beginner language (trust me, been there done that, wasn't fun!) and that's a fact but there's no such thing as a "best" programming or scripting language. They all have their uses and specialties, like anything in life!

    StackOverflow.com will close your question to answers if you ask that kind of question anyway for the same reasons I just outlined here.

    Lua is really a great beginners langauge imho. You don't have to worry about datatypes, managing memory, or pointer problems!

    I really love that the game is so easily moddable though. All games should be like that in my opinion! I am in disbelief that its not more common too. NS2 is really a "blank slate" for anything you want to create! It may just be my computer doing something wonky but I think the reason the NS2 icon on my desktop is a blank sheet of paper is because its a metaphor for what the game is. A blank sheet, a clean slate, a powerful environment for creating amazing things!
  • ChizzlerChizzler Join Date: 2013-01-04 Member: 177532Members
    I've not spent much time looking at the files, so don't quote me on this, but I imagine there's a wealth of transferable information on creating mods for "Garry's Mod" using LUA.
  • SaltlickSaltlick Join Date: 2013-01-03 Member: 177347Members, Reinforced - Shadow
    I made a single GUI mod just to see what it was like. The most helpful thing for me was looking for mods that did stuff similar to what I wanted to do, subscribing to them and then looking at their code. That helped me a lot when I was trying to figure out how to hook in properly. Otherwise, I was just using Decoda to look at a relevant file, and when I came to a function that wasn't declared inside that file, I searched the project for it so I could see what it was doing. It's tedious, but you really miss a lot of functionality if you're not tracing everything you don't understand.
  • 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 August 2014
    I am currently working at a new guide for modding, which i will hopefully release soon.

    Tips fo you for now:

    To get started with lua all you have to do is to read the official lua book
    Look at http://unknownworlds.com/ns2/time-to-make-the-mods/
    Then look at lua/entry
    Look at other mods code like ns2+ at github
    Use ns2docs and the search in files function of your IDE to find stuff.

    Also don't start with modding the gui as the gui system of ns2 is imho the most annoying part of the ns2 code.

    Wait for my guide :D
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    Just be aware, hooking is only suitable for admin/external type mods and minor gameplay mods. While it can be used for total conversion mods, I would highly recommend not using hooking and overwriting the game from scratch. It works out better in the long run for a massive customised mod.

    Of course, Sewlek has made his massive mod with the entry system, but it is a from the ground up build..
  • clankill3rclankill3r Join Date: 2007-09-03 Member: 62145Members, NS2 Map Tester, Reinforced - Shadow
    Maybe it's an idea to have a google drive document? Lua scripters could have write permissions and the rest can just read. I think a document like that can be better in the long run since it's easier to edit by multiple people etc..
  • 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
    Soul_Rider wrote: »
    Just be aware, hooking is only suitable for admin/external type mods and minor gameplay mods. While it can be used for total conversion mods, I would highly recommend not using hooking and overwriting the game from scratch. It works out better in the long run for a massive customised mod.

    Of course, Sewlek has made his massive mod with the entry system, but it is a from the ground up build..

    MvM, Combat, Factions use hooking your argument is invalid :D
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    Combat is built using hooking, but breaks constantly and has massive performance issues because it is just hooked onto base NS2. As a result, combat standalone has been written without using hooks, despite it being an option they were considering due to previous experience with the system.

    MvM and Factions have been re-written from the ground up and while they use the hook entry system, they could just as easily not. Ultimately it is a matter of preference, but personal experience has shown me hooking adds extra overhead to your mod, so for large scale game projects, I believe it is best not to hook.
  • Racer1Racer1 Join Date: 2002-11-22 Member: 9615Members
    Given this is a new NS2 mod developer, I'd say the better question is:
    What is the easiest way to begin? (even if it is slower)

    Although I am not a mod developer (but am a programmer), I'd bet that changing the existing code is the best way to start. It is easier to figure out what you are doing if you can see all of the code around it. Later, after you've got wet feet, you can refactor your code to be hooked in.
  • 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 August 2014
    Racer1 wrote: »
    Given this is a new NS2 mod developer, I'd say the better question is:
    What is the easiest way to begin? (even if it is slower)

    Although I am not a mod developer (but am a programmer), I'd bet that changing the existing code is the best way to start. It is easier to figure out what you are doing if you can see all of the code around it. Later, after you've got wet feet, you can refactor your code to be hooked in.

    I personally would recommand to start working with the shine framework. It provides you with tons of usefull classes and functions.
    Protects ns2 from you breaking it and takes care for you to do the hooking etc.

    If you like to get started with shine plugin developing, start with reading all articles here https://github.com/Person8880/Shine/wiki#for-developers

    Overall before touching ns2 game code please start with getting used to lua itself: http://www.lua.org/pil/contents.html

    I don't recommend to learn lua with ns2. If you want to start learning lua with a game start with modding gmod (to get also used to OOP)
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    Why?

    I have learned to program by starting modding NS2. I have never learned anything about lua or anything else. I just dived into modding NS2 4 years ago. It is easy to follow the code and understand what is going on, because it is a high level language.

    So I started with making a few small mods, and then upgraded to make Proving Grounds and GorgeCraft. While I can honestly say I still do not consider myself a real programmer, if I was learning by learning lua first, I would have quit programming as it is boring as hell.

    However, because NS2 is so moddable, the ideal place to learn is by jumping into the code. You can very quickly make changes and most importantly, get to see actual genuine progress. It is this progress and inspiration that encourages you to keep going. I would whole-heartedly advise to start by diving into ns2 and changing code.

    From 4 years ago not being able to program at all, to now developing a new game in Lua and C++ on a new engine, all because I just dived into modding NS2. I haven't studied Lua yet, or C++, and yet I am programming a new game in both languages. I am designing a entity component system, as it seems to be a much better solution for games than traditional hierarchies, but again, all this comes from one thing. Experience of diving right into NS2.

    I 100% recommend diving straight into the ns2 code and changing things as the best way of learning. You can create amazing work, even if you don't know how to programme. You learn the programming side of things as you are creating the game you want to make. This is much more fun and much more likely to keep new devs interested in what they are doing.
Sign In or Register to comment.