![]() Let's create a new class (we'll get to creating classes in separate files later). In this case, we're going to stick with Lua defined objects. In Lua, there are two types of objects: those defined in C++ (called userdata) and those defined within Lua (special tables). Examples of constructors in Garry's Mod are ents.Create, vgui.Create, and Vector. A constructor basically makes a copy of the class and returns it as a new object. This is an example of an inheritance hierarchy from a hypothetical system comprised of Weapons and Agents. The weapon has all the properties of an entity, such as position and model, and it has its own special properties, such as clip size and damage. An example of this is the HL2 "weapon_pistol", which is based off the "weapon" class, which is based off the "anim" class, which is based off the "entity" class. As more classes are created, a baseclass tree begins to form. Most classes have a baseclass, from which they inherit their properties. Things like Vectors and ConVars are also classes but they aren't created from files, which is the purpose of this tutorial. Examples of classes are Entities, Weapons (which are just fancy entities), and Panels. What is an Object?Īn object in programming is a collection of data which is organized and structured in a specific manner and is derived from a class. ![]() Though this tutorial focuses on application in GMod, the code and concepts can be used elsewhere. This tutorial discusses the methods used by Garry's Mod to define new objects classes from files.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |