Can't figure out MaterialEx:setTexture()

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
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Can't figure out MaterialEx:setTexture()

Post by minmay »

MaterialEx:setTexture(string, string)

There is a crash if the second parameter is not a valid texture asset path, so it must be the texture that will replace the existing one. So I would assume that the first parameter is the name of the texture slot to change. But I've tried everything I can think of for the first parameter and nothing has gotten a result:
"diffuseMap"
"diffuse"
"dif"
"normalMap"
"normal"
etc.
The material still shows its old textures afterwards. Does anyone know what I can enter to actually change a visible texture?
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
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Can't figure out MaterialEx:setTexture()

Post by petri »

Try g_diffuseMap, g_normalMap, etc.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Can't figure out MaterialEx:setTexture()

Post by minmay »

That still doesn't work for me. For example:

Code: Select all

defineMaterial{
	name = "test",
	diffuseMap = "assets/textures/common/white.tga",
	doubleSided = false,
	lighting = true,
	alphaTest = false,
	blendMode = "Additive",
	textureAddressMode = "Wrap",
	glossiness = 0,
	depthBias = 0,
	onUpdate = function(self, time)
		print("test")
		self:setTexture("g_diffuseMap","assets/textures/common/black.tga")
	end,
}
"test" gets printed to the console so I know the onUpdate hook is executing, and other operations like setParam, setTexcoordScaleOffset work fine. But any model given this material just stays white.
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
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Can't figure out MaterialEx:setTexture()

Post by petri »

You're right, it doesn't work :/ This feature was never tested because it is not used by the main campaign. Added to the bug list.
Post Reply