Ameshi Posted January 17, 2015 Posted January 17, 2015 Hi guys, Im getting a index error when I try do that. Im using GetParent() and SetSortMode() Script.pai = nil --entity "pai" --To get the parent function Script:Start() self.pai = self.entity:GetParent() end --change the z-sort self.pai.material:SetSortMode(false) Error: attempted to index field 'material" (a nil value) Quote
nick.ace Posted January 17, 2015 Posted January 17, 2015 http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/ Don't use self.pai.material, use self.pai.mat. You're getting an error because the field is mat and not material. You can also use GetMaterial instead if you wanted to. Quote
Ameshi Posted January 17, 2015 Author Posted January 17, 2015 (edited) Thanks for the help I changed to self.pai.mat:SetSortMode(false) error: attempt to call method 'SetSortMode' (a nill value) I tried: local material = self.pai:GetMaterial() material:SetSortMode(false) or material.mat:SetSortMode(false) attempt to index local 'material' (a nil value) EDIT: error message Edited January 17, 2015 by Ameshi Quote
nick.ace Posted January 17, 2015 Posted January 17, 2015 material.mat:SetSortMode(false) Material isn't an entity, so you can't get the material. For this though: local material = self.pai:GetMaterial() material:SetSortMode(false) You may need to use this instead (I'm currently away from my computer): http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/model/modelgetsurface-r344 So, you grab the Surface of the entity, and then get the Material. Something like this: local surface=self.pai:GetSurface(0) local material=self.pai:GetMaterial() material:SetSortMode(false) Also, does your model have 1 material attached to it or multiple materials? Basically, a surface is, well, as surface. It's the class that handles the actual geometry. In Leadwerks, the surface is instantiated, so a change in a surface will change all of the entities with that surface (this improves performance but prevents some customization). Each surface can have a material assigned to it. Quote
Ameshi Posted January 17, 2015 Author Posted January 17, 2015 I know its not the best solution but to fix my problem I did this: local material = Material:Load("Models/sc_models/props/sa_lamp/bra_outside.mat") material:SetSortMode(false) 1 Quote
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.