AggrorJorn Posted March 7, 2010 Share Posted March 7, 2010 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. Quote Link to comment Share on other sites More sharing options...
Rick Posted March 7, 2010 Share Posted March 7, 2010 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. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 7, 2010 Author Share Posted March 7, 2010 thanks i'll give that a try Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.