[Help] Scripting a combination lock with buttons.

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Arrkangel
Posts: 2
Joined: Sun Sep 09, 2012 6:35 pm

[Help] Scripting a combination lock with buttons.

Post by Arrkangel »

First of all this editor is awesome. So user friendly and clean.
Ill be here for days..ha

I have read up on the modding tutorials on scripting a combination lock for levers and done that and had no problems. I then tried with buttons and i came into a few problems. I tried reading the Scripting Reference too but i seem to be doing something wrong.

i suppose not being that good at scripting does hinder me, any suggestions?
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

Re: [Help] Scripting a combination lock with buttons.

Post by cromcrom »

What about describing your problems ?
A trip of a thousand leagues starts with a step.
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: [Help] Scripting a combination lock with buttons.

Post by Komag »

There is no getButtonState on the scripting reference list, so I'm not sure it will work like that. I did something similar with pressure plates, but had to use an extra step to transition it to levers:
viewtopic.php?f=14&t=3032
Finished Dungeons - complete mods to play
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: [Help] Scripting a combination lock with buttons.

Post by petri »

Komag wrote:There is no getButtonState on the scripting reference list, so I'm not sure it will work like that. I did something similar with pressure plates, but had to use an extra step to transition it to levers:
viewtopic.php?f=14&t=3032
Buttons have no state. They simply activate when they're pressed.
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: [Help] Scripting a combination lock with buttons.

Post by Komag »

Ah yes, that makes sense!
Finished Dungeons - complete mods to play
Magus
Posts: 56
Joined: Wed Sep 12, 2012 6:05 pm

Re: [Help] Scripting a combination lock with buttons.

Post by Magus »

You need to store the pressed button with a variable because buttons don't have on/off states
Custode
Posts: 15
Joined: Wed Oct 10, 2012 8:29 pm

Re: [Help] Scripting a combination lock with buttons.

Post by Custode »

I have found a way to do it, it is a little laborious but it works.
I am not completely sure if this is already been done, if not let me know and I will write the process and show a little example with three buttons as a starting point.
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: [Help] Scripting a combination lock with buttons.

Post by Grimwold »

A relatively simple way to do it, should be to have a counter for each button and a script to check the values of the counters.

Each time a button is pressed its associated counter would be incremented. There'd also be a check values button to test the combination... if checking was done every time a button was pressed you would get a situation where you could spam the final button until you got the right value. The check values button would double as a reset for the counters back to their starting values in case of failure.
Last edited by Grimwold on Fri Oct 12, 2012 1:25 pm, edited 2 times in total.
Custode
Posts: 15
Joined: Wed Oct 10, 2012 8:29 pm

Re: [Help] Scripting a combination lock with buttons.

Post by Custode »

Grimwold wrote:A relatively simple way to do it, should be to have a counter for each button and a script to check the values of the counters.

Each time a button is pressed its associated counter would be incremented and the script would check the values... if all counters had their respective correct values the script would open a door... You'd also need a reset button to set all counters back to their starting values in case of failure.
I guess there are multiple ways to achieve the same or similar results, anyway in my case there is no need for a reset button, when the correct combination is given the script opens the door otherwise it remains closed and you can keep pushing the buttons how many times you like.
Anyway, I have not seen any other discussion about this and I thought it was still unused due to some "limitation" of the editor, should I post my solution? I esitate because I don't want to write something that maybe is already well known.
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: [Help] Scripting a combination lock with buttons.

Post by Grimwold »

I'd go ahead and post your solution anyway... Many of the threads here have multiple ways to do things.
Post Reply