Torch item in ring slot?

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
User avatar
ratman
Posts: 158
Joined: Fri Jan 10, 2020 1:13 am

Torch item in ring slot?

Post by ratman »

Is it possible to make an item like a torch, but instead it makes light when in the character's ring slot? Thanks.
User avatar
Zo Kath Ra
Posts: 931
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Torch item in ring slot?

Post by Zo Kath Ra »

ratman wrote: Wed Oct 21, 2020 12:01 am Is it possible to make an item like a torch, but instead it makes light when in the character's ring slot? Thanks.
This example should get you started.
You have to change the properties of the light component to make it look the way you want.
Unfortunately, I can't help you here, because I don't know what most of the LightComponent properties are for.

Code: Select all

defineObject{
	name = "torch_ring",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/brace_fortitude.fbx",
		},
		{
			class = "Item",
			uiName = "Torch Ring",
			description = "A magic ring that provides light.",
			gfxIndex = 75,
			weight = 0.15,
			traits = { "bracers" },
			onEquipItem = function(self, champion, slot)
				print("onEquipItem")
				if (slot == ItemSlot.Bracers) then
					print("on")
					local light_component = party:createComponent("Light", "torch_ring")
					light_component:setBrightness(15)
				end
			end,
			onUnequipItem = function(self, champion, slot)
				print("onUnequipItem")
				if (slot == ItemSlot.Bracers) then
					print("off")
					party:removeComponent("torch_ring")
				end
			end,
		},
	},
}
@Isaac
Why did you delete your answer?
It was good, in fact this code is based on it.
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Torch item in ring slot?

Post by Isaac »

Zo Kath Ra wrote: Wed Oct 21, 2020 1:15 pm @Isaac
Why did you delete your answer?
It was good, in fact this code is based on it.
I am not at home, and working on an underpowered windows tablet. I had trouble testing the answer, and found that the only thing that seemed to work was enabling or disabling the light component; changes to the component settings weren't working as expected.

*Also the tablet settings were the lowest render quality. :(
User avatar
ratman
Posts: 158
Joined: Fri Jan 10, 2020 1:13 am

Re: Torch item in ring slot?

Post by ratman »

Thank you, this is very helpful. :D (the reason I needed this is because my dungeon is single-player, so I figured it would just make it harder if they had to use one of their hands holding a torch)
Post Reply