Destroy Torchholder with torch
Posted: Tue Mar 26, 2013 3:32 am
Hey there,
Asking if someone already worked on this:
I want to destroy a torchHolder.
If i just destroy the torchHolder and there's a torch inside, the torch just stands floating there.
So I need to make an entitiesAt search for torches (easy with if entity:getFuel() then...) and delete them also, but how to avoid deleting torches if the torch is on the floor instead of in the torchholder?
One way I though of doing this is:
1. check if torchHolder:hasTorch()
2. if yes, cycle through all torches in the tile
3. foreach, destroy it storing facing property, check if still torchHolder:hasTorch() and if not assume that was the one, else respawn that torch on the floor with same facing and try next one.
Another idea:
1. check if torchHolder:hasTorch()
2. get number of torches in the tile
3. destroy all torches, storing facing properties, then respawn torchesNumber - 1 on the ground with same facing.
What do you guys think? Or if anyone has already a working (better) solution...
Asking if someone already worked on this:
I want to destroy a torchHolder.
If i just destroy the torchHolder and there's a torch inside, the torch just stands floating there.
So I need to make an entitiesAt search for torches (easy with if entity:getFuel() then...) and delete them also, but how to avoid deleting torches if the torch is on the floor instead of in the torchholder?
One way I though of doing this is:
1. check if torchHolder:hasTorch()
2. if yes, cycle through all torches in the tile
3. foreach, destroy it storing facing property, check if still torchHolder:hasTorch() and if not assume that was the one, else respawn that torch on the floor with same facing and try next one.
Another idea:
1. check if torchHolder:hasTorch()
2. get number of torches in the tile
3. destroy all torches, storing facing properties, then respawn torchesNumber - 1 on the ground with same facing.
What do you guys think? Or if anyone has already a working (better) solution...