Gabriel Posted November 3, 2011 Share Posted November 3, 2011 Hello I have few object in my scene, and i link the Horse1 with Horse2 with Link(0) I try with this code and the responce stay the same "not linked" :% function class:CreateObject(model) .... for n=0,7 do chemin = model:GetTarget(n) if chemin == nil then Notify("Not Linked") else Notify(";-)") end end .... the responce stay the the same :-) Not Linked,Not Linked,Not Linked,Not Linked,Not Linked,Not Linked,Not Linked Please Help me ;-) Gabriel Quote Link to comment Share on other sites More sharing options...
Josh Posted November 3, 2011 Share Posted November 3, 2011 That looks right, but I would need to see your scene to try it myself. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted November 3, 2011 Share Posted November 3, 2011 the target is not set immediately after creation of the class... if you create the local object and then place the code inside an object function like 'object:UnlockKeys()' that would normally get called automatically, it would work... but thats just a guess on what is happening because you are apparently removing code from the script, so it is hard to guess... also your explanation is confusing... if it finds the link in any of the possible 8 available targets, it should return ;-) and you said this is what it returns: :-) Not Linked,Not Linked,Not Linked,Not Linked,Not Linked,Not Linked,Not Linked which is correct... the '0' link returns ;-) and the other 7 that have no targets return 'Not Linked' 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...
Gabriel Posted November 3, 2011 Author Share Posted November 3, 2011 the target is not set immediately after creation of the class... if you create the local object and then place the code inside an object function like 'object:UnlockKeys()' that would normally get called automatically, it would work... but thats just a guess on what is happening because you are apparently removing code from the script, so it is hard to guess... also your explanation is confusing... if it finds the link in any of the possible 8 available targets, it should return ;-) and you said this is what it returns: which is correct... the '0' link returns ;-) and the other 7 that have no targets return 'Not Linked' Hi macklebee Oup you are right, the smilies was ironic, but you guessed it. The application does not find the links and then goes 8 times by the MessageBox ("pfff"). I tried your solution, if you are right then I think the event "UnlockKey" come too soon! In the tutorial, I see that using this method in an event "Update", so I do have'm also without success :-( To overcome this problem, I try another method "GetChild" which works perfectly in "C / C + +" because I instantiate the object "scene". example: TEntity LoadScene scene = ("abstract:: test.sbx"); Entity = cheval1 FindChild (scene, "ch1"); " But in Lua in my model, I do not know how to have access to the object "scene", I even assumed that the parent object was the scene, but in return I have a nice access violation: - ( Is there an event for the end of the creation of the scene? If you have an idea it is welcome. Quote Link to comment Share on other sites More sharing options...
macklebee Posted November 3, 2011 Share Posted November 3, 2011 this works for me when i link to another object... require("scripts/class") local class=CreateClass(...) function class:CreateObject(model) local object=self.super:CreateObject(model) function object:UnlockKeys() for n=0,7 do chemin = model:GetTarget(n) if chemin == nil then else Notify(";-)") end end 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...
Gabriel Posted November 3, 2011 Author Share Posted November 3, 2011 Ok i try again your code in my object Many thanks for your help Quote Link to comment Share on other sites More sharing options...
Gabriel Posted November 4, 2011 Author Share Posted November 4, 2011 Hi macklebee It works great , But I thought it would give me the "TEntity" with GetTarget function :-( i think it gives me the "TModel", type(GetTarget(0)) return "userdata" could you tell me how to retrieve the object "TSurface" starting from a model? Thank you for your invaluable help, Gabriel 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.