ENT.Initialize

From GMod Wiki

Revision as of 08:13, 11 October 2010 by Jcw87 (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Event Hook
Hook NameInitialize
SyntaxENT:Initialize( )
DescriptionCalled right before the entity spawns.
ReturnsNil
Lua StateNewerShared.png
BBCode[b][url=wiki.garrysmod.com/?title=ENT.Initialize]ENT.Initialize [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionDo startup stuff
Used onNewerServer.png
Code
function ENT:Initialize()
    self:SetModel("models/dav0r/buttons/button.mdl")
end
OutputSets the model to a button right before spawning.


Additional Notes

DescriptionRun code before calling initializer
Used onNewerServer.png
Code
myEnt=ents.Create("my_ent_type")
myEnt:DoStuff("Hi",23,54)
myEnt:Spawn()
OutputDoes stuff before Initialize is called.


myEnt's initialize hook appears to happen right before myEnt:Spawn() is executed. This should allow you to run functions on the entity before initializing if that is necessary.

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox