Ask a simple question, get a simple answer

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
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: Ask a simple question, get a simple answer

Post by Drakkan »

another simple question - could be object chest somehow reworked that you need some key type to open it, not (just) lockpick ? I saw definition, but there is nothing mentioned about it.
EDIT: hmm actualy there is lock component mentioned, but nothing about a lockpick...

Code: Select all

		{
			class = "Model",
			name = "lock",
			model = "assets/models/env/treasure_chest_lock.fbx",
			offset = vec(0, 0.41406, 0.54883),
			enabled = false,
		},
not sure how its working, seems hardcoded ?
Breath from the unpromising waters.
Eye of the Atlantis
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Ask a simple question, get a simple answer

Post by GoldenShadowGS »

There was a thread about this, try searching the forum.
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: Ask a simple question, get a simple answer

Post by Drakkan »

GoldenShadowGS wrote:There was a thread about this, try searching the forum.
got it ! thanks
viewtopic.php?f=22&t=8405&hilit=treasure+chest+lock
Breath from the unpromising waters.
Eye of the Atlantis
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: Ask a simple question, get a simple answer

Post by bongobeat »

Hello, I m looking for a script that open a door while pressing 4 buttons, in the correct order.

this is beyond my knowledge so if someone can help?

it has to be like: right button has to be pressed 4x, then left button 2x, bottom button 1x, then right again 3x, bottom 2x , upper button 2x

(4x, 2x, ..., are just examples, any number, depend on the desired combination)

And if you press it more than it needs, for any button, it reset the script.
like if you need to press right button 8x, and you press it 9x, the script is reseted.

Don't know if this is clear? :roll:
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: Ask a simple question, get a simple answer

Post by Drakkan »

bongobeat wrote:Hello, I m looking for a script that open a door while pressing 4 buttons, in the correct order.

this is beyond my knowledge so if someone can help?

it has to be like: right button has to be pressed 4x, then left button 2x, bottom button 1x, then right again 3x, bottom 2x , upper button 2x

(4x, 2x, ..., are just examples, any number, depend on the desired combination)

And if you press it more than it needs, for any button, it reset the script.
like if you need to press right button 8x, and you press it 9x, the script is reseted.

Don't know if this is clear? :roll:
create script called buttonpuzzle and insert following script

Code: Select all

isCompleted = false
counter = 1

function click(button)
	if not isCompleted then
		local seq = { 
			"puzzlebutton1",
			"puzzlebutton1",
			"puzzlebutton2",
			"puzzlebutton3",
			"puzzlebutton4",
		}
		
		-- checks that buttons are pressed in correct order
		if seq[counter] == button.go.id then
			playSound("key_lock")
			counter = counter+1
		else
			counter = 1
		end
		
		-- checks if the combination has been completed
		if counter == #seq+1 then
			puzzledoor.door:open()
			isCompleted = true
			counter = nil
		end
	end
end
- create 4 buttons called puzzlebutton1, puzzlebutton2, puzzlebutton3, puzzlebutton4
- create door called puzzledoor
- redirect all buttons to the script.

As you can see you just put correct "seqence" of the button inside the script which need to be pushed to open the door (in this case 2x button 1, 1x2 1x3 1x4. If wrong button pushed, everything is reseted. You can also remove the "click" sound from the script in case you do not want hint player if he is clicking in good order.
Breath from the unpromising waters.
Eye of the Atlantis
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Ask a simple question, get a simple answer

Post by GoldenShadowGS »

Heres mine

You can change "44441133323" to the combination of your own choice. This is the order the buttons should be pressed in. press button 4 four times, then button 1 twice, etc...
The combination can be any length from one digit to as many as you want. Your buttons can be named anything, but must have only one number per button. Button one must have "1" somewhere in its ID.Button two must have "2" in its ID.

You can change the number of buttons in the combination by changing this line:

Code: Select all

for i = 1,4 do
change the "4" to the number of buttons in your combination lock.

The only other thing you need to do is link all the buttons to the script function "buttonCombination" and change the line

Code: Select all

dungeon_door_portcullis_1.door:open()
to do whatever it is you want to happen when the combination is entered successfully.

Code: Select all

combination = 44441133323
comb = {}
count = 0
solved = false

function buttonCombination(self)
	--if solved == false then
		count = count + 1
		for i = 1,4 do
			if string.match(self.go.id, i) then
				print(count)
				print(string.len(combination))
				if count <= string.len(combination) then
					comb[count] = i
					local order = table.concat(comb)
					local s, b = string.find(combination, order)
					print(s,b)
					print(order)
					if s == 1 and b == count and count < string.len(combination) then
						playSound("key_lock")
					elseif s == 1 and b == string.len(combination) then
						playSound("key_lock")
						dungeon_door_portcullis_1.door:open()
						solved = true
					else 
						playSound("lock_incorrect")
						for r = 1,string.len(combination) do
							comb[r] = nil
						end
						count = 0
						dungeon_door_portcullis_1.door:close()
					end
				else
					playSound("lock_incorrect")
					for r = 1,string.len(combination) do
						comb[r] = nil
					end
					count = 0
					dungeon_door_portcullis_1.door:close()
				end
			end
		end
	--end
end
Last edited by GoldenShadowGS on Tue Dec 09, 2014 3:29 am, edited 8 times in total.
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Ask a simple question, get a simple answer

Post by msyblade »

Dammit JKos, I just put the kudos box up, and now I have to dig it back out to give you 2 more!
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: Ask a simple question, get a simple answer

Post by bongobeat »

thanks all!

try mode on ;)


edit:
both amazing script for me, works well, thank you!

I use both of them :D
Last edited by bongobeat on Tue Dec 09, 2014 8:35 pm, edited 1 time in total.
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
TheLastOrder
Posts: 104
Joined: Wed Oct 17, 2012 1:56 am

Re: Ask a simple question, get a simple answer

Post by TheLastOrder »

Watching this tutorial:

https://www.youtube.com/watch?v=-YlAZwq ... Nc&index=7

It comes to my mind that somehow you need to stop the script once it has finished. Otherwise, the game crashes if you put BANE back into the altar and you pick it again, as long as the monster doesn't exist anymore...

Do I need a Boolean or something to stop that?
I tried this
dungeon_alcove_magma:destroy()
but the game crashes.

So the simple question is:

How to stop calls into scripts for BOSSFIGHTS that can't be triggered again?
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: Ask a simple question, get a simple answer

Post by Grimfan »

Sometimes it's the simple things...

I spawned a lot of buttons for a puzzle. What is the best method via a script of destroying them? It's something that should be easy (well it was in LOG 1) but it's giving me nightmares.

Any help would be great. :)
Post Reply