Page 1 of 2

ConbinationLevers

Posted: Fri Jun 26, 2015 7:54 pm
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

Re: ConbinationLevers

Posted: Fri Jun 26, 2015 8:05 pm
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

Re: ConbinationLevers

Posted: Fri Jun 26, 2015 8:13 pm
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:

Re: ConbinationLevers

Posted: Fri Jun 26, 2015 9:38 pm
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

Re: ConbinationLevers

Posted: Sat Jun 27, 2015 12:29 am
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

Re: ConbinationLevers

Posted: Mon Jun 29, 2015 2:58 pm
by Kuro01
Thanks!

Re: ConbinationLevers

Posted: Tue Aug 18, 2015 9:09 pm
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

Re: ConbinationLevers

Posted: Tue Aug 18, 2015 9:19 pm
by Kuro01
I guess I can do it all in one didn't think about that. 1-25 other than 5 seperrate

Re: ConbinationLevers

Posted: Tue Aug 18, 2015 9:26 pm
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

Re: ConbinationLevers

Posted: Tue Aug 18, 2015 9:59 pm
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.