Garry's Mod Wiki


  table baseclass.Get( string name )


Gets the base class of an an object.

This is used not just by entities, but also by widgets, panels, drive modes, weapons and gamemodes (with "gamemode_" prefix).

The keyword DEFINE_BASECLASS translates into a call to this function. In the engine, it is replaced with:

local BaseClass = baseclass.Get
You should prefer using this instead of self.BaseClass to avoid infinite recursion.

For more information, including usage examples, see the BaseClasses reference page.


1 string name
The child class.


1 table
The base class's meta table.


Inherits the weapon from weapon_csbasegun and calls its base functions

AddCSLuaFile() DEFINE_BASECLASS( "weapon_csbasegun" ) //this is equivalent to local BaseClass = baseclass.Get( "weapon_csbasegun" ) //omitted generic swep definitions function SWEP:Initialize() BaseClass.Initialize( self ) //calls SWEP:Initialize() from weapon_csbasegun self:SetHoldType( "pistol" ) end function SWEP:Deploy() self:SetAccuracy( 0.9 ) return BaseClass.Deploy( self ) //calls SWEP:Deploy() from weapon_csbasegun and returns its result end function SWEP:SetupDataTables() BaseClass.SetupDataTables( self ) //calls SWEP:SetupDataTables() from weapon_csbasegun and inits its dtvars end