Page 1 of 1

Torch item in ring slot?

Posted: Wed Oct 21, 2020 12:01 am
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.

Re: Torch item in ring slot?

Posted: Wed Oct 21, 2020 1:15 pm
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.

Re: Torch item in ring slot?

Posted: Wed Oct 21, 2020 7:28 pm
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. :(

Re: Torch item in ring slot?

Posted: Thu Oct 22, 2020 3:03 am
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)