ENT.Initialize

From GMod Wiki

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