Page 27 of 396

Re: Ask a simple question, get a simple answer

Posted: Sat Dec 06, 2014 7:17 pm
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 ?

Re: Ask a simple question, get a simple answer

Posted: Sat Dec 06, 2014 7:56 pm
by GoldenShadowGS
There was a thread about this, try searching the forum.

Re: Ask a simple question, get a simple answer

Posted: Sat Dec 06, 2014 9:07 pm
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

Re: Ask a simple question, get a simple answer

Posted: Mon Dec 08, 2014 8:40 pm
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:

Re: Ask a simple question, get a simple answer

Posted: Mon Dec 08, 2014 9:01 pm
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.

Re: Ask a simple question, get a simple answer

Posted: Mon Dec 08, 2014 9:48 pm
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

Re: Ask a simple question, get a simple answer

Posted: Mon Dec 08, 2014 11:48 pm
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!

Re: Ask a simple question, get a simple answer

Posted: Tue Dec 09, 2014 12:11 am
by bongobeat
thanks all!

try mode on ;)


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

I use both of them :D

Re: Ask a simple question, get a simple answer

Posted: Tue Dec 09, 2014 2:29 am
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?

Re: Ask a simple question, get a simple answer

Posted: Tue Dec 09, 2014 3:27 am
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. :)