Garry's Mod Wiki

baseclass.Get

  table baseclass.Get( string name )

Description

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

Arguments

1 string name
The child class.

Returns

1 table
The base class's meta table.

Example

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