Please, i need that when the players place the "red gem" on the altar, all the torches spawns in the room (only once, and only where there aren't torches).
is this possible?
(sorry for bad english, but i'm italian

Code: Select all
TorchHolder:hasTorch()
Code: Select all
TorchHolder:addTorch()
Code: Select all
function itemPuzzle()
-- Test Altar and Torches
for i in altar_sud:containedItems() do
if i.name == "red_fragment" then
for i in allEntities(party.level) do
if i.name == "torch_holder" then
i:addTorch()
end
end
end
end
end
end
I think you can't use another for loop with the same variable ("i") inside another loop.Dinasty wrote:Can someone post me the right code please? Thanks!Code: Select all
function itemPuzzle() -- Test Altar and Torches for i in altar_sud:containedItems() do if i.name == "red_fragment" then for i in allEntities(party.level) do if i.name == "torch_holder" then i:addTorch() end end end end end end
Code: Select all
function itemPuzzle()
-- Test Altar and Torches
for altarItem in altar_sud:containedItems() do
if altarItem.name == "red_fragment" then
for i in allEntities(party.level) do
if i.name == "torch_holder" then
i:addTorch()
end
end
end
end
end
Code: Select all
mycounter = 1
function itemPuzzle()
for altarItem in altar_sud:containedItems() do
if altarItem.name == "red_fragment" then
if mycounter == 1 then
for i in allEntities(party.level) do
if i.name == "torch_holder" then
i:addTorch()
mycounter = 0
end
end
end
end
end
end
Code: Select all
function itemPuzzle()
-- Test Altar and Torches
for altarItem in altar_sud:containedItems() do
if altarItem.name == "red_fragment" then
for i in allEntities(party.level) do
if i.name == "torch_holder" and i:hasTorch() == false then
i:addTorch()
end
end
end
end
end