Putting out torches in torch holders

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
Ulfsark
Posts: 18
Joined: Sun May 05, 2013 5:52 pm

Putting out torches in torch holders

Post by Ulfsark »

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!
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Putting out torches in torch holders

Post by Komag »

Destroy all torches in torchholder square, then add dead torch
Finished Dungeons - complete mods to play
Ulfsark
Posts: 18
Joined: Sun May 05, 2013 5:52 pm

Re: Putting out torches in torch holders

Post by Ulfsark »

Komag wrote:Destroy all torches in torchholder square, then add dead torch
Are torch holders considered containers? If I were to add a dead torch I would use something akin to this correct?

Code: Select all

torchholder_id:addItem(deadtorch_id)
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Putting out torches in torch holders

Post by Komag »

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
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Putting out torches in torch holders

Post by JohnWordsworth »

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:

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
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!
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
Ulfsark
Posts: 18
Joined: Sun May 05, 2013 5:52 pm

Re: Putting out torches in torch holders

Post by Ulfsark »

Sounds good, Thanks a lot guys, I will let you know what I manage to get working if anything.

Thanks!
Post Reply