• Where to start with GLua
    10 replies, posted
Yes, I've tried the wikia and learned some basic syntax, but is there any way I can dive deeper? I can't start a custom Nutscript RP server if all I know is how to do File New and type in print(createserver). Basically, a place that I can rely on for help and a beginner's project.
Pick apart some other stuff, try to learn how it works, then play around with stuff on the GMod wiki. If stuff breaks and gives you errors, that's fine, since you'll learn what you did and how to fix it.
Make a: HUD - good practice with on screen 2d elements Admin Menu - networking & vgui Warn System - learn to save data Some sort of stat list maybe idk A 3D info bar which is shown above players A health and armor charger for entity practice A chat box? Garry's Mod ^^ Your Baby ^^ Beginner Tutorial Intro Just remember to maintain a logical point of view.
Making a cheat is always pretty good, teaches you basically everything you need to know about GMod lua.
Ya if you do all this you will be a pretty good gmod coder.
Dropbox Read up on the basics - feel free to add me on Steam and I can send more... unfortunately my old links do not work because Dropbox cut off access to the public folder for paying and non-paying accounts. I'm trying to figure out how to link more than one account to this new forum and get my gold account back...
I had 0 Idea of lua whatsoever, then i watched <CODEBLUE> lua and gmodlua videos, and i got the basics of luas within days, within 1/2 weeks i started creating my own HUD which is in the workshop by now, has several versions and works great. I suggesst you to watch his videos as well. He shows lua itself, and after that gmod lua
This isn't a jab at Acecool but: I haven't read through everything there but OP you will likely be better off to avoid using Acecool's coding style. It works for him but you're not likely to run into a similar style anywhere else, even outside of glua, at least in that combination. Many parts of his style can be found across different languages and communities, but you'll experience a lot of friction when working with the generally available glua code out there if you're used to his style. Don't let that discourage you from reading the rest of his tutorial though. He's by no means a poor coder.
i use tabs for indentation also nil checking is something you should do alot of nullchecking is also something you should do function func_to_too_call_on_entities(ent) if ent and ent:IsValid() then --do stuff end end "if ent" checks to make sure it's not nil "and ent:IsValid() then" checks to make sure it's not null most entity functions will throw lua errors if they are called on a null entity
nil checking shouldn't really be something you have to do if it's with entities. No engine functions or hooks will provide nil instead of an entity (minus some special cases due to bugs), and your Lua API shouldn't either if formatted correctly.
In general nil checking functions is a sign of a more fundamental problem with how you are considering pre and post conditions for function calls in your programs. Calling a function is a contract that you will provide it with the correct parameters, and handle its output correctly. For beginner programmers using https://www.lua.org/pil/8.3.html assert may be useful as it allows you to get errors early if you call a function you wrote incorrectly, but errors are a VERY important feature of languages -- they let you know when something is wrong, or an expectation that SHOULD be met is not being met. In most cases you should not really be wanting to suppress them, but rather when you find them you should figure out why you are getting them, and modify your functions expectations accordingly to handle them. All of this being said, invalid entities do very realistically pop up in weird places sometimes in Gmod Lua so an IsValid check is reasonable, nil on the other hand I think should be an error.
Sorry, you need to Log In to post a reply to this thread.