Torch item in ring slot?
Posted: 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.
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,
},
},
}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.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.