ENT.SetupDataTables
From GMod Wiki
Revision as of 01:10, 15 October 2010 by Unrealomega  (Talk | contribs)
				
			| Event Hook | |
| Hook Name | SetupDataTables | 
| Syntax | ENT:SetupDataTables( ) | 
| Description | Sets up networked variables for use with an Entity. | 
| Returns | Nil | 
| Lua State |   | 
| BBCode | [b][url=wiki.garrysmod.com/?title=ENT.SetupDataTables]ENT.SetupDataTables [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] | 
Examples
| Description | Sets up two float networked variables, TargetZ and Speed | 
|---|---|
| Used on |  | 
| Code | function ENT:SetupDataTables() self:DTVar( "Float", 0, "TargetZ" ); self:DTVar( "Float", 1, "Speed" ); end | 
| Output | N/A | 
| Description | Usage after initializing the variables, as seen in the above example. | 
|---|---|
| Used on |  | 
| Code | self:SetDTFloat(0, 1.0) self:GetDTFloat(0) self.dt.TargetZ | 
| Output | N/A | 
Additional Notes
- This should be used over Networked Variables, when possible.
- You can manipulate a variable directly with self.dt.<Networked Variable Name>, though it's not suggested.
- Excerpt taken from Garry's blog: "The base entity in GMod has a 24 extra variables on it, networked. This is kind of icky, but it’s the best way to do it. There’s 4 of each type available – int, float, vector, angle, ehandle, bool. On the ground level there’s functions for each type to get and set these variables – ent:SetDTBool( int, value ) – ent:GetDTBool( int )."
 
			
			