Okay, I wanted to make it so players couldn't try throwing the torch across the darkness triggers to avoid having them go out. The original script that snuffs out inventroy and moue held torches, which I have named "darkness", works fine:
Code: Select all
TF = {}
TID = {}
function torchout()
for i=1,4 do
for j=1,31 do
if party:getChampion(i):getItem(j) ~= nil then
local istorch = party:getChampion(i):getItem(j)
if istorch.name == "torch" and istorch:getFuel() ~= 0 then
table.insert(TID,istorch)
local fuel = istorch:getFuel()
table.insert(TF,fuel)
istorch:setFuel(0)
end
end
end
end
local mtor = getMouseItem()
if getMouseItem() ~= nil and mtor.name == "torch" then
table.insert(TID,mtor)
local fuel = mtor:getFuel()
table.insert(TF,fuel)
getMouseItem():setFuel(0)
end
end
function torchrestore()
print(TF[1])
print(TID[1])
for i=1,25 do
local tor = TID[i]
if tor ~= nil then
tor:setFuel(TF[i])
end
end
for i=1,4 do
for j=7,8 do
if party:getChampion(i):getItem(j) ~= nil then
local istorch = party:getChampion(i):getItem(j)
party:getChampion(i):removeItem(j)
party:getChampion(i):insertItem(j, istorch)
end
end
end
end
But the extra script I made to detect thrown/ground torches seems work until it's time to relight them:
Code: Select all
spawn("timer",self.level,self.x,self.y,0,self.id.."gcheck")
:setTimerInterval(0.1)
:addConnector("activate", self.id, "groundcheck")
:activate()
function groundcheck()
for i in entitiesAt(self.level, self.x, self.y) do
if i.name == "torch" and i.getFuel ~= 0 then
local fuel = i:getFuel()
table.insert(darkness.TID,i)
table.insert(darkness.TF,fuel)
i:setFuel(0)
end
end
end
I'm pretty sure it's adding to the tables correctly, since the print functions in torchrestore() show the fuel and torch being added to the table, but torch won't relight like it does if it was put out the other two ways.