Hey guys, I am trying to put out all of the torches in a room except for the one the player is holding, so this would only put out the ones that are in torch holders.
I looked around and could not find anything on how to disable ones in torch holders. Simply destroying the entity would remove the torch holder as well correct? If anybody could point me in the right direction I would appreciate it.
Thanks!
Putting out torches in torch holders
Re: Putting out torches in torch holders
Destroy all torches in torchholder square, then add dead torch
Finished Dungeons - complete mods to play
Re: Putting out torches in torch holders
Are torch holders considered containers? If I were to add a dead torch I would use something akin to this correct?Komag wrote:Destroy all torches in torchholder square, then add dead torch
Code: Select all
torchholder_id:addItem(deadtorch_id)
Re: Putting out torches in torch holders
Yeah, it's right there in the scripting reference, but you need to spawn a torch, set its fuel to 0, and add it, all on the same line
Finished Dungeons - complete mods to play
- JohnWordsworth
- Posts: 1397
- Joined: Fri Sep 14, 2012 4:19 pm
- Location: Devon, United Kingdom
- Contact:
Re: Putting out torches in torch holders
Unfortunately, I don't think torchholders have a removeItem() method. It might do, but it's not documented in the scripting reference (they might have forgotten to add it, or it might not be supported).
If it's not supported, I think you could do the following:
Then just call the above method from any script doing putOutTorchInHolder(torchholder_1);
Note, this is untested, so might not work - but in principal, I think it should!
If it's not supported, I think you could do the following:
Code: Select all
function putOutTorchInHolder(holder)
if ( holder == nil ) then
print("Attempted to put out torch in a nil torchholder!");
return nil;
end
if ( holder:hasTorch() ) then
local id, level, x, y, facing = holder.id, holder.level, holder.x, holder.y, holder.facing;
holder:destroy();
holder = spawn("torch", level, x, y, facing, id);
holder:addItem(spawn("torch"):setFuel(0));
end
end
Note, this is untested, so might not work - but in principal, I think it should!
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
Re: Putting out torches in torch holders
Sounds good, Thanks a lot guys, I will let you know what I manage to get working if anything.
Thanks!
Thanks!