
Thanks in advance.
How do you do that? I'm sorry, I'm a complete newbie.Neikun wrote:A clunky workaround might be to destroy the torch holder with the torch in it while simultaneously spawning an empty one?
Code: Select all
function leftEyeRemoved()
-- cycle through items at my torch holder location
for k in entitiesAt(party.level, 4, 17) do
-- if the items name has "torch" then destroy/remove the item
if string.find(k.name, "torch") then
k:destroy()
end
end
-- Spawn a new torch holder at the exact same location, with the same id. This allows for continued use if desired
spawn("torch_holder", party.level, 4, 17, 3, "eyeTorchLeft")
end
This little trick helped me immensely. I actually set out to do the same thing as the original poster: remove a torch from it's holder. But that torch holder also has about five connectors. After destroying it and replacing it, how can I add the connectors again? I've tried adding lines after the spawn line with "torchholder:addconnector()" but I get this error: "attempt to index global 'torch_holder_10' (a nil value)". Here's my code...crisman wrote:You'll have to take the coordinates of the torch holder. the script should looks like:
Ps: this script will only extinguish the torch inside the torch holder. I think its a beautiful effect!!Code: Select all
function torches() torch_holder_i:destroy() spawn("torch_holder", party.level, x, y, facing, "torch_holder_i") --gave an ID to the torch holder so you can repeat the script as you wish end
If you want to actually destroy the torch, well... I'll have to figure it out, because, right now, I don't know
Code: Select all
-- Starts a timer for function torchSnuffed()
-- extinguishes a torch placed in the holder after 1 second.
function noTorch4U()
if torch_holder_10:hasTorch() == true then
timer_noTorch4U:activate()
end
end
-- appears to snuff out the torch in the holder by destroying
-- the holder and instantly adding a new one.
function torchSnuffed()
torch_holder_10:destroy()
spawn("torch_holder", party.level, 21, 5, 1, "torch_holder__10")
torch_holder_10:addConnector("activate", temple_door_darkness, "close")
end
--gave an ID to the torch holder so you can repeat the script as you wish
Code: Select all
-- Starts a timer for function torchSnuffed()
-- extinguishes a torch placed in the holder after 1 second.
function noTorch4U()
if torch_holder_10:hasTorch() == true then
timer_noTorch4U:activate()
end
end
-- appears to snuff out the torch in the holder by destroying
-- the holder and instantly adding a new one.
function torchSnuffed()
torch_holder_10:destroy()
spawn("torch_holder", party.level, 21, 5, 1, "torch_holder_10")
torch_holder_10:addConnector("activate", "teleporter_5", "activate")
torch_holder_10:addConnector("activate", "timer_1", "activate")
torch_holder_10:addConnector("activate", "timer_2", "activate")
torch_holder_10:addConnector("activate", "teleporter_9", "activate")
torch_holder_10:addConnector("activate", "DestroysTorchlight", "noTorch4U")
end
--gave an ID to the torch holder so you can repeat the script as you wish