Rellek Posted July 8, 2011 Share Posted July 8, 2011 Right, so it's rather easy to find a specific entity in a scene when running a LUA program outside the sandbox editor, i.e.: scene=LoadScene("MyScene") myobject=scene:FindChild("MyObjectName") It's obviously not that simple to do when running the script from within the Editor, and although I have spent many hours reading through our forums, there still doesn't seem to be a satisfactory answer of doing the same from a LUA script running within the editor, simply because there is no "scene" object to refer to - it's not being loaded anywhere in the code for obvious reasons. So, in short - what object/entity can I refer to in place of the scene to find a specific child entity of the scene by it's name key or am I on the "wishful thinking" track here? Is the scene itself (within the editor) a member of the CurrentWorld() or global framework object for example or do I have to start referring to global classnametables and objecttables to achieve this? All I am really trying to do is to get a reference to a specific directional light within my scene to do some sun path tracking from code running inside the edtor - NOT code using engine.exe from the outside. Assistance from anyone in this matter will be much appreciated. Quote Link to comment Share on other sites More sharing options...
Canardia Posted July 8, 2011 Share Posted July 8, 2011 The scene object is just a temporary container when loading a sbx file. It should be completely emptied after the scene has been loaded. You don't even always have a scene, for example when you load the scene from a sqlite3 database. After that you can do world:FindChild("name"). Not sure if that works though, since world is not a real entity, but then you have to code that function yourself. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Rellek Posted July 8, 2011 Author Share Posted July 8, 2011 The scene object is just a temporary container when loading a sbx file. It should be completely emptied after the scene has been loaded. You don't even always have a scene, for example when you load the scene from a sqlite3 database. After that you can do world:FindChild("name"). Not sure if that works though, since world is not a real entity, but then you have to code that function yourself. Nope, unfortunately the entities within the scene (when RUNNING WITHIN THE EDITOR) are definitely not children of the world entity - I have tried that before. Perhaps Josh can tell us how we can access a pointer to a specific entity saved within the sbx file when running the LUA code from within the Editor and don't have a scene=LoadScene("MyScene") entry anywhere in the code. Quote Link to comment Share on other sites More sharing options...
Canardia Posted July 8, 2011 Share Posted July 8, 2011 I think world:GetChild(0) or 1 is the scene graph, so maybe that has the models as childs then, haven't tried. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
macklebee Posted July 8, 2011 Share Posted July 8, 2011 require("scripts/linkedlist") for entity in iterate(fw.main.world.entities) do if entity:GetKey("name")=="light_directional_1" then --Do Something end end Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Rellek Posted July 8, 2011 Author Share Posted July 8, 2011 require("scripts/linkedlist") for entity in iterate(fw.main.world.entities) do if entity:GetKey("name")=="light_directional_1" then --Do Something end end Thank's very much macklebee - that worked first time and solved a problem I've been battling with for some time now. Quote Link to comment Share on other sites More sharing options...
macklebee Posted July 8, 2011 Share Posted July 8, 2011 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel 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.