How do you make your Lua scripting mods?
TooMuchFun
NunyaBiznizz Join Date: 2014-04-28 Member: 195653Members
in Modding
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?
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
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.
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!
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
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
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.
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)
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.