Community Forum

setMaterial function

Forum Overview >> Scripting

CategoryScripting
Created17.05.2015 16:26


Fred Zanella (fredzaza2) 17.05.2015 16:32
Hi , can somebody give me an exemple for this function please ?

setMaterial(integer shapeId,integer materialId,integer material index)

i want to change the skin of my vehicule with an key, but i don't know how define the argument

Fredzaza

Fabian Sch (Unknown) 17.05.2015 17:11
Hi,
first you should manually add materials to your shape:

<Shape nodeId="XY" materialIds="19, 20, 30" ... />

then get to know which you added (materialIds may change when editing or importing it with GE):

self.switchMaterials = {}
local nrMaterials = getNumMaterials(nodeId) or 0
for i=1,nrMaterials do
local materialId = getMaterial(nodeId, (i-1))
table.insert(self.switchMaterials,materialId)
end

and then you can change them with:

setMaterial(nodeId, self.switchMaterials[1])


Fred Zanella (fredzaza2) 17.05.2015 17:14
ok , thanks you for your help, i go try this

Fred Zanella (fredzaza2) 17.05.2015 19:45
the script is FUNCTIONAL, thank you again for your help


Note: Log in to post. Create a new account here.