How to script torch holders?

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: How to script torch holders?

Post by Grimfan »

What Prozail said though you can also use getItem() instead of getHasTorch() for torch holders, as in...

Code: Select all

function TorchPuzzle1()
    if t1.socket:getItem() and t2.socket:getItem() then
        dungeon_secret_door_10.door:open()
    else
        dungeon_secret_door_10.door:close()
    end
end
Last edited by Grimfan on Tue Oct 28, 2014 12:22 pm, edited 1 time in total.
User avatar
Jouki
Posts: 127
Joined: Fri Oct 24, 2014 12:57 pm

Re: How to script torch holders?

Post by Jouki »

Mysterious wrote:Ok I have 2 torch holders named t1 and t2. The first to Scripts work, but the 3rd Script does not. Does anyone know how to fix this I have tried for 3 hours lol. :)

function TorchPuzzle1()

if t1.controller:getHasTorch() == true and
if t2.controller:getHasTorch() == true then ---Error is here---
If you want create a multiply condition you can use only 'and'. The second 'if' is not required. btw if you want negative you condition write 'not' for example:

Code: Select all

if t1.controller:getHasTorch() == true and not
t2.controller:getHasTorch() == true then
yeah this is a bad example because a return value of conditions are boolean but if you have something like

Code: Select all

if not counter1.counter:getValue() == 5 and
t2.controller:getHasTorch() == true then
bla bla bla bla
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Re: How to script torch holders?

Post by Mysterious »

Hi ok I have this atm:

1 - counter called. counter1 value = 5
1 - Torch called. t2

I have connected t2 to the Script, thinking when I take the torch out after 5 times the door would open, but the door does not open. I am not sure what I am doing wrong, I thought the counter1 decrements auto like. I would also like to have multiple torch holders to open the door e: t1, t2, t2 etc.. Some may need torches some not. Thxs for any assistance :)

Code: Select all

function torchpuz1a()

if not counter1.counter:getValue() == 5 and
t2.controller:getHasTorch() == true then

dungeon_door_wooden_11.door:open()

end
end
User avatar
Jouki
Posts: 127
Joined: Fri Oct 24, 2014 12:57 pm

Re: How to script torch holders?

Post by Jouki »

If you mean this one: video

here's the guide:

Code: Select all

torchCounter = 0
function DoItFiveTimes()
	torchCounter = torchCounter + 1
	if torchCounter >= 5 then ourDoor.door:open() end
end
Image
Post Reply