1. Inheritance. Before I started playing with the Source Engine I had no idea of how to use inheritance. In fact, when coding all of my NPCs in Facewound the code was copied and pasted directly from another NPCs to build upon.
2. Interfaces. Interfaces kind of changed the way I approach nearly everything in my coding. Putting specific things into a separate DLL forces you to make your code more modular. It also encourages reusable code, speeds up compiles and I guess it reduces bugs (or at least makes it more obvious where they are).
3. I don’t like Lua so much. I know it’s a weird thing to say, considering how much GMod uses Lua.. but if I could do it again I’d really try to use something different if it existed. Lua has a lot of good stuff, but some things are annoying. Like the syntax. It seems like they do stuff to be different. They say it’s to make it more newbie friendly, but how is
--[[
This is a comment
--]]
more newbie friendly than
/*
This is a comment
*/
It isn’t, it’s just being different for the sake of it. Plus none of the fundamentals like |, <<, +=, -=, *=, /=, &= or |=. Not newbie friendly I'm afraid. I don't see why adding them would mean that newbies would have to use them. I guess I just want it to be PHP. I wonder if you could use PHP as a game scripting language..
4. Separate drawing and thinking. In Facewound all the objects would think as they were being drawn. So if you had 60fps, the AI was thinking 60 frames a second. The movement code was like
x = x + xvel * frametime
y = y + yvel * frametime
In retrospect, they should have been separated. The AI should have thought like 10 times a second, and draw should have lerped between the new and old positions automatically.
5. Vectors. I thought I understood Vectors until I used Source, but Source makes it all so simple compared to something like the DirectX SDK. Things like discovering Forward, Right and Up vectors were like huge epiphanies.
6. Matrices. Matrices are easy. I’ve never been that great at maths (got C in school (10 years ago)). But luckily enough you don’t really have to be to use them. It’s just basic shit like rotate this much, move this much, scale this much. It always seems crazy how all the game dev books/websites I read made them seem so complicated, actually telling you about the numbers inside. You don’t really need to know that. It’s like telling someone about assembly when all they want to do is add two numbers. I mean look at this shit.
7. Source Control. I never used Source control until about GMod version 5. It’s invaluable in bug tracking. For example, you find a bug that shows up in version 6 but not 7. You just diff the changes in the code. Or maybe you start pursuing something that turns out to be a big load of shit, you just revert your code to what it was. Plus it’s another backup of your code if things go tits up. ANd if you’re making something open source, you can host it at google – you don’t even need to set up a SVN server.
8. Visual Assist Rocks. It’s so hard to go back to coding without it once you have it for a couple of weeks.
9. Do it properly. Adding hacky shortcutty crap to your code might not seem like much at first, but it’s 100x harder to fix it and do it right when so much other code depends on that hack. Take the time to do it right the first time will save a lot of time in the long run.
10. Don’t trust modders. If you’re giving people the opportunity to mod your game, they’re going to be doing dumb stuff.
For example, in GMod getting a lot of text from the server to the client can be a bit of a chore because you can only send just under 255 characters at a time. So some modder, in his infinite wisdom, sends console commands to the client which clears the console, writes out a bunch of text, then condumps. He can then open up the condump file and the text is there. Yeah that works, but it’s a huge fucking hack and ends up generating 100′s of condump334.txt files in your garrysmod folder.
“A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools.”
Kewl
Good read.
That’s Nice
As far as I know there’s no implementation of PHP for any games, but I suppose that mainly due to it being horribly slow – Lua / Python etc. have a huge advantage there. Possibly it’s only a matter of implementation though.
Apart from this there’s also some other uses of PHP besides the typical Apache Module: Combinations with GTK to create applications with GUIs and also a plugin for Miranda (Instant Messenger) called MSP (Miranda Scripting Plugin) which allows for easy modifications in the IM’s behavior without C knowledge.
neat. =)
Wow.Simply mindbending matrices.
I mean, look at the “Advanced” Matrices page.I’m no wiz at math or calculating, but I knew, that is complicated for anyone.Atleast reading it.
Wow, interesting reading. I never used facewound but it must have been a big jump!
Yeah, you are right about LUA. I use PHP too and it is really very annoying to make a comment in LUA.
About point 9 you are complety right too. You can better just do it the first time right than fix or adjust everything later because it is MUCH more work!
Hi @ all! I’ve got a big Question which is very short: Where can I download a playable version of garrys mod 9??? I’ve only got garrys mod 1 and all the other mods which I’ve already loaded dont function!!!
HELP!!!
Number 9 is exactly why I always write my code twice. First I do a crappy version, just to make sure everything works. Then I remove it and rewrites a nice and clean version. It’s incredibly easy to do, because you’ve got it all in your head.
Not sure how that would work on such a big scale as this though xD
#9 is easier said than done. I think it’s one of those things you can really teach to new coders. You just have to let them make the mistakes so they learn first hand. Mostly because they’ll never listen.
I recommend you to use Python as scripting language. It should be easy to embed and once you’ve learned how to use it, you will never want to go back.
Nice but no Update on the Gmod game?
I don’t code, but this was still a great post Garry. That Visual Assist thing looks fantastic.
Another vote for Python. List slicing and comprehension rock. It has very easy bindings to C++.
It still doesn’t do the C style /* comment */ though!
I’d like to revise my comment in your last post by saying that instead of having a “Spawn Prop Frozen” checkbox on the spawnmenu, make it so when they right click on an icon, the prop spawns frozen.
Regarding #9… the rule of thumb is, you have to do it wrong before you can do it right. Unless you’re John Carmack.
Reading over that wiki page on Matrices, I don’t see how it differs, in programming terms, from a two-dimensional array and how vectors differ from one-dimensional arrays.
What a true blog post, as the virual assits, it seemed quite awesome at the frontpage, then I discovered it wasn’t freeware. PHP could be a serious alternative, as it’s freeware and thus should be implementable, but it’s too late now, Garry should’ve done it properly from a start. ;-)
The ‘Do it properly’ is exactly what I’m trying to do with my own silly project of creating the most intelligent AI yet. There’s only one question left, do you do it properly? :P
Visual Assist looks awesome, but $150? Is it really worth it?
“For example, in GMod getting a lot of text from the server to the client can be a bit of a chore because you can only send just under 255 characters at a time. So some modder, in his infinite wisdom, sends console commands to the client which clears the console, writes out a bunch of text, then condumps. He can then open up the condump file and the text is there. Yeah that works, but it’s a huge fucking hack and ends up generating 100’s of condump334.txt files in your garrysmod folder.”
Haha HuntsKikBut fails at being smart.
If you’re making a mod that’s being used by thousands of people, and you’re actually living off of, I suppose it’s worth it xD
hey i thing python will be good too :D. and good job garry ;)
I never knew what you meant when you just said “condump”. That was so fucking ridiculous.
Conna,
The fun can not be halted.
@24
Hahahaha. Win.
Well, as for the blog post, basically all I have to say is this: Yes.
I don’t know anything about coding, but you sure are one optimistic dude Garry :D
“9. Do it properly” Isn’t only good in coding, it’s good to do it in a proper way when you… Well, do anything really C:
I wish I would sit down, and learn how to code/script stuff, I just don’t have the patience :(. I’ve spent $50 on books that teach C++, etc, and I’ll always get bored as shit and go play CS:S or something after reading 2 pages, and it’s like nothing I read in the tutorial stuff sticks, it just goes in and straight out of my brain.
Garry, how did you start to learn PHP/LUA/C, etc, and do you have any tips for someone wanting to learn to code/script with C++/PHP? I’ve heard a lot of people say that actually opening up the source code of things, and learning by figuring out how it works is how they did it, and I’ve tried that but I never understand it, so I turn to tutorials and I lose interest in the tutorials almost instantly, because they are too newbie friendly, and they are explaining things so into detail like “Open up your internet browser, and click in the address bar, and type http://www.asdf.com/” instead of “Go to asdf.com”.
Anyways, enough rambling on, but if you have any tips for someone wanting to learn PHP/C++, could you e-mail me at admin@aljaud.com? Thanks for taking the time to read this, hope to hear from you soon :).
How about TCL?
http://en.wikipedia.org/wiki/Tcl
Or lisp. :P
“but how is
–[[
This is a comment
--]]
more newbie friendly than
/*
This is a comment
*/”
”
Because now you’re think–[[
]]–ing with portals.
When the AMX Mod team made their API they used an implementation of what was then called “SMALL”, and whose name has since changed to “Pawn” (http://www.compuphase.com/pawn/pawn.htm).
The c like syntax of it would probably be more to your liking, and the whole language was created with the intent to be implemented. It’s also open source.
Check it out.
“3. I don’t like Lua so much.”
I think GMod would of been better off with something like GameMonkey. I don’t like Lua syntax as well, I’m more accustomed to the c/perl syntax.
“4. Separate drawing and thinking”
You’re thinking of an Accumulator so it runs the same on every computer. I use this mainly for my physics engine, for other stuff you can simply use delta time as a multiplier.
Here’s a code snippet(hope it pastes properly).
Accumulator += deltaTime;
while( Accumulator >= timeStep )
{
for( int i = 0; i < PointMassSystems.Count; i++ )
{
PointMassSystems[ i ].Update( timeStep );
}
Accumulator -= timeStep;
}
You didn’t know how to use inheritances?
Wow, and all this time I actually thought you knew more than I did, when you don’t even know some of the most basic of things.
Well, good thing that you learned how to use the inheritances, they really save time. I used them in my particle engine and it helps a ton.
Oops, didn’t read. I thought you meant you just learned it now. Still, I thought you knew about it when making Facewound, and that surprises me.
I’ve been working on my own C-based syntax (except with weakly-typed variables a la PHP) scripting language. Right now I have a parser which can separate a script into keywords (IE if I type “function something()” it understands that’s a function keywords, followed by a variable name “something” followed by an open parenthesis and a close parenthesis). Not much I know, but it’s enough to make a syntax highlighter already, and part of a syntax checker.
The next step I’d need to do is create a class hierarchy to store higher level information (IE: a Script class, with a Function class array plus an array of Expressions. It’d be more complex than that but that’s enough to give you an idea.) and then a second parser and script validater to translate scripts into this higher level format. Then I can finally start writing code to run scripts. The only problem is it might not be fast… I won’t know until I try it.
You don’t need the — before the double close brackets at the end of a lua comment, people just think it looks cool
Hurray! I was mentioned! :D
But do remember that was like two fucking weeks into GM10 and no one had discovered how to use user messages because we had no fucking documentation. If you want to blame someone, Garry, blame yourself.
@21
Haha, Conna fails at being unbanned.
I have to say, I don’t like –[[ ]] block-comments either. But where you added all the !=, &&,||, */ /*, // operators etc, you destroy any syntax highlighting. It really sucks when I open some luas coded for GMod on my with gedit on linux just to see, some comments are fucking the whole syntax highlight.
Unless I’m mistaken, some benchmarks indicate that Python is faster than PHP. But Lua is faster still and I don’t think small things like += and multi line commenting (possibly influenced by [[multi-line strings]]) can take away that advantage.
Disregard the shit I spewed a few replies ago, I suck cock.
Hey garry, something happened to my gmod and I cant seem to download anything! was it a update that messed it up or something because i cannot download anything :(
r u in war of the servers
Hello could someone tell me their thoughts on a good download torrent service. What free service would you recommend?