G.AccessorFunc

From GMod Wiki

Revision as of 20:52, 11 November 2009 by Crazy Quebecer (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax AccessorFunc( Table tab, String varname, String name[, Integer iForce] )
Where is this used?
Description:
Quickly make Get/Set accessor fuctions on the specified table
Returns: nil
Part of Library: Global Functions
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=G.AccessorFunc]G.AccessorFunc [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionThis function creates two new functions on the table you deliver which simply do nothing else but setting a variable to another value.
Used onNewerClient.png
Code
 -- This creates two new functions "SetErect" and "GetErect" which will allocate a value to ENT.Erected
 AccessorFunc(ENT,"Erected","Erect");
 
 function ENT:StartTouch()
  if(not self.Erected) then -- Instead of self.Erected you could use self:GetErect()
   self:SetErect(true)
  end
 end
 
 function ENT:EndTouch()
  self:SetErect(false)
 end
OutputN/A


Additional Notes

SHARED | 0000000000000001 | 00000000000000001 | STRING
SHARED | 0000000000000002 | 00000000000000010 | NUMBER
SHARED | 0000000000000003 | 00000000000000011 | BOOL

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox