Code: Select all
function torchEquipped()
local hasTorch = false
for i = 1,4 do
local c = party.party:getChampionByOrdinal(i)
hasTorch = hasTorch or checkSlotForTorch(c, 1) or checkSlotForTorch(c, 2)
end
return hasTorch
end
function checkSlotForTorch(champion, slot)
local torchInSlot = false
local j = champion:getItem(slot)
if j then
torchInSlot = (j.go:getComponent("torchitem") ~= nil)
end
return torchInSlot
end
this line sends errormahric wrote:Jouki, I think the torchEquipped() script below should do the trick.
It checks all the champions with an item in their hand with the "TorchItemComponent", which should for all torches.
However, there might be other items with lightsources that don't have this component. This script does not check for those.
Code: Select all
function torchEquipped() local hasTorch = false for i = 1,4 do local c = party.party:getChampionByOrdinal(i) hasTorch = hasTorch or checkSlotForTorch(c, 1) or checkSlotForTorch(c, 2) end return hasTorch end function checkSlotForTorch(champion, slot) local torchInSlot = false local j = champion:getItem(slot) if j then torchInSlot = (j.go:getComponent("torchitem") ~= nil) end return torchInSlot end
*I was wrong... I get a different error...Jouki wrote:..."getItem a nil value", I have no idea why is it doing, it looks everything is right...
Code: Select all
function check()
print(torchEquipped())
end
Isaac wrote:*I was wrong... I get a different error...Jouki wrote:..."getItem a nil value", I have no idea why is it doing, it looks everything is right...
Ah... This happened when I called the wrong function.
Try this:
Temporarily add this to the script and call it with a button.It should [when the button is pressed] print true or false ~whether anyone has a torch equipped. It's a neat script.Code: Select all
function check() print(torchEquipped()) end
I don't know if that's possible; it was not [really] possible in LoG1.Jouki wrote: btw could you write script checking if the spell "light" is actived, please? ^^
Code: Select all
-- Returns true if the Light spell is activated.
function lightSpellOn()
-- no light source: 0.1, 0.13, 0.25
-- torch: 1.2, 0.8, 0.6
-- light spell: 0.56, 0.75, 1.2
-- both: 1.76, 1.55, 1.8
return party.torch:getColor()[3] > 1.19
end
This is new...minmay wrote:Code: Select all
-- Returns true if the Light spell is activated. function lightSpellOn() -- no light source: 0.1, 0.13, 0.25 -- torch: 1.2, 0.8, 0.6 -- light spell: 0.56, 0.75, 1.2 -- both: 1.76, 1.55, 1.8 return party.torch:getColor()[3] > 1.19 end
wow, thanks. It's much easier way to figure out.minmay wrote:Code: Select all
-- Returns true if the Light spell is activated. function lightSpellOn() -- no light source: 0.1, 0.13, 0.25 -- torch: 1.2, 0.8, 0.6 -- light spell: 0.56, 0.75, 1.2 -- both: 1.76, 1.55, 1.8 return party.torch:getColor()[3] > 1.19 end