Garry's Mod Wiki

Garry's Mod Wiki

  DEFINE_BASECLASS( string value )

Description

Generates and provides a local variable BaseClass that can be used to call the original version of a class functions after modifying it.

This is a preprocessor keyword that is directly replaced with the following text:

local BaseClass = baseclass.Get

Because this is a simple preprocessor keyword and not a function, it will cause problems if not used properly

See baseclass.Get for more information.

The preprocessor is not smart enough to know when substitution doesn't make sense, such as: table keys and strings.

Running print("DEFINE_BASECLASS") is the same as print("local BaseClass = baseclass.Get")

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

Arguments

1 string value
Baseclass name

Example

Showcase Demonstration from the sandbox gamemode code

DEFINE_BASECLASS( "gamemode_base" ) --Establish the var BaseClass to hold the original base gamemode functions function GM:PlayerSpawn( pl, transiton ) --overriding the original function with our own player_manager.SetPlayerClass( pl, "player_sandbox" ) --Adding our extended functionality BaseClass.PlayerSpawn( self, pl, transiton ) -- Calling the original GM:PlayerSpawn so still get original functionality end
Output: Original Spawning Mechanics with the addition that players now spawn with player_sandbox class

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...