setMaterialOverrides does not work on rendered object

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

setMaterialOverrides does not work on rendered object

Post by MrChoke »

I have been calling setMaterialOverrides() in my code for quite some time with no issues. But I guess it is not until now that I want to call it on an object that has already been rendered. Now I call it and it doesn't work. Is there some way I can force the game re-render an object? I tried disable/enable on the model component. That did not work.

Thanks
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: setMaterialOverrides does not work on rendered object

Post by minmay »

Dynamic setMaterialOverrides() works fine for me. Are you sure the table you're passing is naming the right materials, accounting for previous overrides?
For example, if you've previously done setMaterialOverrides({material1="material2"}) then setMaterialOverrides({material1="material3"}) won't do anything; you need to use setMaterialOverrides({material2="material3"}) because you changed material1 to material2.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: setMaterialOverrides does not work on rendered object

Post by Isaac »

Ninja'd... But you don't even need the parenthesis; it's a table.

Code: Select all

function override() forest_ogre_1.model:setMaterialOverrides{forest_ogre_club = "healing_crystal_black1"} end

delayedCall(self.go.id, 0, "override")


*However... What works in the console, does not seem to work in a script_entity. Delayed Call() fixes this.

Image
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

Re: setMaterialOverrides does not work on rendered object

Post by MrChoke »

minmay wrote:Dynamic setMaterialOverrides() works fine for me. Are you sure the table you're passing is naming the right materials, accounting for previous overrides?
For example, if you've previously done setMaterialOverrides({material1="material2"}) then setMaterialOverrides({material1="material3"}) won't do anything; you need to use setMaterialOverrides({material2="material3"}) because you changed material1 to material2.
Minmay, I think you are right! I will confirm. Good catch.
Post Reply