BadJeanBon Posted May 4, 2017 Share Posted May 4, 2017 Hi ! I just want to know if it is possible to have acces the Model method in a lua script that has been attached to a model in the scene editor. I wanna do something like my_model = tolua.cast(self.entity , "Model") my_surface = my_model:GetSurface(0) I want a script that I can attach to any model in a map scene... Thanks. Quote Link to comment Share on other sites More sharing options...
Genebris Posted May 4, 2017 Share Posted May 4, 2017 Yes, it is possible. 1 Quote Link to comment Share on other sites More sharing options...
BadJeanBon Posted May 5, 2017 Author Share Posted May 5, 2017 Thanks for your reply Genebris But I did test it, and it doesn't seem to work straight from the script attached. I guess I could load the model from the main.lua so I could declare it global and access it on a private script... but that wasn't my goal. I was just curious to know if it could done, that is, to attach a script to a model entity and to use it to animate the vertex of an object for exemple ... I read the forum, and it seem that lua script only access the entity...It's ok... I was just asking, as a beginner , to be sure I wasn't missing something simple here... Thanks again for your answer.... Quote Link to comment Share on other sites More sharing options...
Genebris Posted May 5, 2017 Share Posted May 5, 2017 If something doesn't work, you should post error that you get. What you wrote is supposed to work. Quote Link to comment Share on other sites More sharing options...
Einlander Posted May 5, 2017 Share Posted May 5, 2017 mySurface = Self.entity:GetSurface(0) Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted May 5, 2017 Share Posted May 5, 2017 Try lowercase 'self' Quote Link to comment Share on other sites More sharing options...
BadJeanBon Posted May 5, 2017 Author Share Posted May 5, 2017 Doesn't work , when i attach this script to a box: function Script:Start() mySurface = self.entity:GetSurface(0) System:Print(mySurface:CountVertices()) end I get this error at line 2: 2 : attempt to call method 'GetSurface' (a nil value) and the script stop with a requester. Quote Link to comment Share on other sites More sharing options...
Genebris Posted May 5, 2017 Share Posted May 5, 2017 On CSG brush you need to cast entity to model like you wrote in the first post. Also, CountVertices() on brush causes crash for some reason, CountTriangles works, though. 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.