I wrote for my mod this script.
If anyone want to use it, feel free.
place an script entity named "torchRest" with this code
Code: Select all
function burnfuelonRest()
if party.party:isResting() then
for i = 1,4 do
if torchEquipped(i, 1) == true then
burnFuel(i, 1)
end
if torchEquipped(i, 2) == true then
burnFuel(i, 2)
end
end
end
end
function torchEquipped(champNum, slot)
local hasTorch = false
local c = party.party:getChampion(champNum)
hasTorch = checkTorch(c, slot)
return hasTorch
end
function checkTorch(champion, slot)
local torchSlot = false
local hasItem = champion:getItem(slot)
if hasItem then
torchSlot = (hasItem.go:getComponent("torchitem") ~= nil)
end
return torchSlot
end
function burnFuel(champ, slot)
local item = party.party:getChampion(champ):getItem(slot)
local torch = item.go:getComponent("torchitem")
local fuel = torch:getFuel()
if torch:getFuel() > 0 then
torch:setFuel((fuel - 1))
elseif torch:getFuel() < 0 then
torch:setFuel(0)
end
endYou also need an Timer with 1 second delay. Connect him to the script entity "torchRest".
Or you can take it easy as i and give the party a timer
Code: Select all
defineObject{
name = "party",
baseObject = "party",
components = {
{
class = "Timer",
name = "torchtimer",
timerInterval = 1.0,
triggerOnStart = true,
onActivate = function(self)
torchRest.script.burnfuelonRest()
end
}
}
}st1nger