Jump to content

Find entity


AggrorJorn
 Share

Recommended Posts

I'm need to find an entity in my scene. I don't need the references but purely the class object. I had a look in the pfd (starting with lua)but no luck with that. At the moment I'm trying something like this:

  
plane = classnametable[ "plane" ] 

	if paint == 1 then
		plane:Paint(texture1)
	end

	if paint == 2 then
		plane:Paint(texture2)
	end

 

The textures are loaded before the loop.

Link to comment
Share on other sites

Here is what I do with this.

 

for k,v in pairs(objecttable) do
		if v.type ~= nil then
			if v.type == "inventory.item" then

 

I give an object a .type field. So like object.type = "iventory.item". Then I look through the objecttable and if the object has a .type field and if it's the right text I know I have the object. From there you can get the class if you like, but you can also call functions from that object. Even functions that you created and are not part of LE.

 

Note also though that this depends on where you are calling it from because of when objects get created. I generally give each object an object:Initialize() method. Then before the main loop in the main lua file I loop through all objects in objecttable and if they have an Initialize() method I call it. I also do the same with a Destroy() method and call them after the main loop ends for some clean up stuff.

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...