• GLua Discussion: Beginner's Learning Curve
    2 replies, posted
Hey Facepunch, you've seen me around the forums lately making dumb comments, assumptions, and just overall not understanding Lua. There are plenty of people that come to this forum that are like me and it seems to cause a lot of frustration - so I thought I'd offer a solution and maybe someone will get something out of this down the line. So here it is: I was wondering if you guys could recommend just some basic projects that I should try to create. Not too hard and not too complex but a series of projects that would help me understand the fundamentals of GLua. There has to be some universal skills that are versatile for many GLua projects. So I was wondering if you guys could tell me what they are, tell me about your experiences (how you learned) and what I can do to improve as a GLua coder. The wiki is at the top of my list and I know I should utilize it more than I do but the issue is that because I'm new I don't know how to PHRASE what I'm trying to find. So I can type something into google but often the search results are misleading because I'm inexperienced. An example: not knowing that players are entity's and googling how to do something with the player server side and then inevitably doing local ply = LocalPlayer() server side. So as a community what would you say are the building blocks of becoming an addon creator. I want to be as flexible, versatile, and knowledgeable as possible so I'd appreciate any project recommendations that you might have. Just so it's clear I've completed both of Code Blue's Lua tutorials. The basic Lua and the Gmod DarkRP Lua. So I've got some experience now but not enough to say "I'm fluent in GLua", obviously. Thanks for any advice, let's please keep this thread polite. Thank you!
The best you can do for yourself and anyone else that will use your code/script is to use well named files names (Don't make everything shared) When creating hooks use your addon name at the start and don't make globals if you reeeally don't need them, you will find your style or whatever it makes glua that fucking amazing
It really helps if you are familiar with the engine. I've been playing Half-life and related games since before steam was ever a thing. I've played with various mods and learned the content creation processes for both GoldSrc and Source. Somewhere in that mix of mods and utilities is when I figured out that players are entities, long before I did any programming and long before Garry decided to write a mod. You don't have to constrain yourself to Lua in your quest for programming knowledge. Many concepts translate easily from most other programming languages. Reading general game development tutorials can give you a general idea of what might be going on under the hood of a large, complicated game engine like Source, and tell you how you can implement some types of behaviors. Up to date OpenGL tutorials (the ones that use shaders and vertex buffers instead of the fixed function pipeline) can give you an idea of how the 3D rendering process works, and would be helpful to anyone wanting to render something in Source. When you are actually writing Lua code, you really need to understand the basics of Lua and some common gotchas that can trip you up if you have experience with other programming languages. Browse the wiki to figure out what Garry's Mod is capable of. Pick a category or library and read the page for every function in it. You won't retain everything you read, but when you need to deal with that concept in the future, you will KNOW you read a wiki page on that exact thing, and will have a better idea of what you should be looking for. If you are struggling with a particular problem, you can dissect existing software and libraries to see how someone else handled it. How does raycasting work? Read the Doom source code and find out! How does a scripting language work? Read the Lua source code and find out! How does that one gmod addon do that impossible (to your knowledge) thing? Read the addon source and find out! Second opinions are important though. Just like with doctors, sometimes the first one you get is absolute shit. My first real programming project was fixing up a buggy php based web game, and it did things in the shitty, SQL injection prone way instead of using prepared statements.
Sorry, you need to Log In to post a reply to this thread.