Global/Add NPC Class

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{Function | Name = Add_NPC_Class | Namespace = Global | Realm = Shared }} {{Syntax | Name = Add_NPC_Class | Description = You can use this function to add your own...")
 
m
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Function
+
{{Func
| Name = Add_NPC_Class
+
|Name=Add_NPC_Class
| Namespace = [[Global]]
+
|Parent=Global
| Realm = Shared
+
|Description=Defines a global entity class variable with an automatic value in order to prevent collisions with other {{Enum|CLASS}}. You should prefix your variable with CLASS_ for consistency.
 +
|Realm=Shared and Menu
 +
|IsClass=No
 +
|File=lua/includes/util.lua
 +
|Line=370-L373
 
}}
 
}}
{{Syntax
+
{{Arg
 
+
|type=string
| Name = Add_NPC_Class
+
|name=name
| Description = You can use this function to add your own CLASS_ var.<br />
+
|desc=The name of the new enum/global variable.
Adding in this way will ensure your CLASS_ doesn't collide with another.
+
}}
| Arg1Name = name
+
{{Example
| Arg1Type = any
+
|Description=Creates a global variable named CLASS_TESTER and prints its value.
| Arg1Req = true
+
|Code=Add_NPC_Class( "CLASS_TESTER" )
| Arg1Desc = N/A
+
print( CLASS_TESTER )
 +
|Output=36 (one greater than the current highest value of the {{Enum|CLASS}})
 
}}
 
}}

Latest revision as of 21:57, 21 February 2019

 Add_NPC_Class( )

Contents

Description

Defines a global entity class variable with an automatic value in order to prevent collisions with other CLASS_ Enums. You should prefix your variable with CLASS_ for consistency.

Arguments

string name

The name of the new enum/global variable.

Examples

Example

Creates a global variable named CLASS_TESTER and prints its value.

Add_NPC_Class( "CLASS_TESTER" )
print( CLASS_TESTER )

Output:

36 (one greater than the current highest value of the CLASS_ Enums)
Personal tools
Navigation