Rick Posted August 14, 2014 Share Posted August 14, 2014 In my training today we were attempting to change the material on a surface of a model that was loaded in the scene at design time. The model was a child of a csg box which was what was being checked for picking. The problem is that we were able to get the child (the actual model) and call Entity functions on it, but not Model functions, which is how you get surfaces. What am I missing on how to get the surface of a model loaded at design time? For example, this works because SetColor() is an Entity function and GetChild() returns an Entity self.entity:GetChild(0):SetColor() This blows up with the function being nil because GetSurface() exists for Models not Entities self.entity:GetChild(0):GetSurface(2) Was looking through the docs and couldn't see any sort of conversion function. Any ideas? Quote Link to comment Share on other sites More sharing options...
shadmar Posted August 14, 2014 Share Posted August 14, 2014 You might need to cast it first, something like this to get its methods : local model=self.entity:GetChild(0) tolua.cast(model,"Model") local surf=model:GetSurface(2) Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
macklebee Posted August 14, 2014 Share Posted August 14, 2014 i believe you are looking for 'tolua.cast(entity,"Model")' edit- shadmar sweeps in with the answer at the buzzer! 1 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...
Rick Posted August 14, 2014 Author Share Posted August 14, 2014 Interesting. Don't recall ever seeing that before. Thank you. Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 14, 2014 Share Posted August 14, 2014 look at the FPSWeapons.lua script - is being used to cast an instance of an emitter to the emitter class 1 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.