Jump to content

Thingoid Initialize method


Rick
 Share

Recommended Posts

I often require to do some code in a Thingoid just once on startup of game mode. Until now I just made a bool variable in a Thingoid and checked it in the Update() method and that's how I did my init code. I've decided to come up with a better way now.

 

Inside your main lua file right before the main loop do this:

for k,v in pairs(objecttable) do
if v.Initialize ~= nil then
	v:Initialize()
end
end

 

Then in your Thingoid you can, but don't have to, define:

 

function object:Initialize()
end

 

You can do this with any kind of function. Enjoy!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...