baseclass.Get
From Garry's Mod
(Redirected from Global/DEFINE BASECLASS)
Contents |
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
string name
The child class.
Returns
The base class's meta table.
Examples
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