ConbinationLevers

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!
User avatar
Kuro01
Posts: 36
Joined: Tue Jun 23, 2015 2:05 pm

ConbinationLevers

Post by Kuro01 »

I been trying to get this to work but no luck maybe someone can help.
Doors is set to - combinationDoor
Levers are set to - combinationLever1, combinationLever2, combinationLever3
All 3 levers connected to script.
error- attempt to call method 'getLeverState' (a nil value)

Script Entity

Code: Select all

-- combination lock puzzle
function pullLever()
	if combinationLever1:getLeverState() == "activated" and
	combinationLever2:getLeverState() == "deactivated" and
	combinationLever3:getLeverState() == "activated" then
		combinationDoor:open()
	else
		combinationDoor:close()
	end
end
User avatar
Kuro01
Posts: 36
Joined: Tue Jun 23, 2015 2:05 pm

Re: ConbinationLevers

Post by Kuro01 »

Never mind I got it to work. I was doing it wrong.

Code: Select all

-- combination lock puzzle
function checkLevers()
    if combination_lever_1.lever:isActivated() and not combination_lever_2.lever:isActivated() and combination_lever_3.lever:isActivated() then
        combination_door.door:open()
    else
        combination_door.door:close()
    end
end
Azel
Posts: 808
Joined: Thu Nov 06, 2014 10:40 pm

Re: ConbinationLevers

Post by Azel »

You can also tie the levers to counters so that you can do "0" vs "1" checks. Tends to make things a bit more manageable sometimes ...

if counter_1:getValue() + counter_3:getValue() == 2 and counter_2:getValue() == 0 then "open door" else "close door"

Something like that :mrgreen:
User avatar
Kuro01
Posts: 36
Joined: Tue Jun 23, 2015 2:05 pm

Re: ConbinationLevers

Post by Kuro01 »

I been using this which works.What would I have to add to the script if a want a trap or monster to spawn if a fail on combination after pushing
button. Anyone have a link on info or add code thanks.

Code: Select all

function testlock()
   if counter_1.counter:getValue() == 1 and
   counter_2.counter:getValue() == 0 and
   counter_3.counter:getValue() == 1 and
   counter_4.counter:getValue() == 0 and
   counter_5.counter:getValue() == 1 then

   test_door.door:open()
   
   else

   test_door.door:close()

   end
end
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: ConbinationLevers

Post by Eleven Warrior »

Hi man try this (function). Simple to implement. There are of course better ways to do this function, but this is easy to understand :) I hope this is what you are after.
The only problem is if the player continues to do the lever, button sequence again and again it will continue to spawn the monster.

Code: Select all

function testlock()
   if counter_1.counter:getValue() == 1 and
   counter_2.counter:getValue() == 0 and
   counter_3.counter:getValue() == 1 and
   counter_4.counter:getValue() == 0 and
   counter_5.counter:getValue() == 1 then

   test_door.door:open()
   
   else
      spawn("herder",1,1,1,1,0)
          party.party:shakeCamera(1,1)  ---Not Needed
            playSound("lighting_bolt_hit",1,1,1,1,0) ---Not Needed
  test_door.door:close()
end
User avatar
Kuro01
Posts: 36
Joined: Tue Jun 23, 2015 2:05 pm

Re: ConbinationLevers

Post by Kuro01 »

Thanks!
User avatar
Kuro01
Posts: 36
Joined: Tue Jun 23, 2015 2:05 pm

Re: ConbinationLevers

Post by Kuro01 »

I been working on a combination lever puzzle but am having some trouble. I have 5 groups of levers with 5 levers in each of them on the wall shaped like a diamond.
I want each on of these groups of levers to open one door when each combination gets solved. I figure I might need a counter but not sure how to make it work in
a script. Can anyone help. I have this setup x5 scripts right now all different combination.

Code: Select all

function checkLevers()
    if combination_lever_1.lever:isActivated() and
       combination_lever_2.lever:isActivated() and
       combination_lever_3.lever:isActivated() and
       combination_lever_4.lever:isActivated() and
       combination_lever_5.lever:isActivated() then

       combination_door.door:open()
    else
       combination_door.door:close()
    end
end
User avatar
Kuro01
Posts: 36
Joined: Tue Jun 23, 2015 2:05 pm

Re: ConbinationLevers

Post by Kuro01 »

I guess I can do it all in one didn't think about that. 1-25 other than 5 seperrate
User avatar
THOM
Posts: 1281
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: ConbinationLevers

Post by THOM »

Don't know if it's exactly, what you are searching for (and it's LoG1 related) but have a look at this great lever-combination-script:

viewtopic.php?f=14&t=4461#p46505
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
Kuro01
Posts: 36
Joined: Tue Jun 23, 2015 2:05 pm

Re: ConbinationLevers

Post by Kuro01 »

Does it work for GR2? I think this will work for what I need. I'll try the other one to you mentioned.

function checkLevers()
if lever_1_1.lever:isActivated() and
lever_2_1.lever:isActivated() and
lever_3_1.lever:isActivated() and
lever_4_1.lever:isActivated() and
lever_5_1.lever:isActivated() and
lever_1_2.lever:isActivated() and
lever_2_2.lever:isActivated() and
lever_3_2.lever:isActivated() and
lever_4_2.lever:isActivated() and
lever_5_2.lever:isActivated() and
lever_1_3.lever:isActivated() and
lever_2_3.lever:isActivated() and
lever_3_3.lever:isActivated() and
lever_4_3.lever:isActivated() and
lever_5_3.lever:isActivated() and
lever_1_4.lever:isActivated() and
lever_2_4.lever:isActivated() and
lever_3_4.lever:isActivated() and
lever_4_4.lever:isActivated() and
lever_5_4.lever:isActivated() and
lever_1_5.lever:isActivated() and
lever_2_5.lever:isActivated() and
lever_3_5.lever:isActivated() and
lever_4_5.lever:isActivated() and
lever_5_5.lever:isActivated() then
playSound("chime_01")

combo_door_1b.door:open()
else
combo_door_1b.door:close()
end
end

I still havan't entered combination yet.
Post Reply