Jump to content

Recommended Posts

Posted

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)
Posted (edited)

Thanks for the help smile.png

 

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 by Ameshi
Posted

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.

Posted

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)

 

smile.png

  • Upvote 1

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...