Page 1 of 1

[Script/puzzle]Moving button (dexterity puzzle)

Posted: Sun Nov 02, 2014 11:52 pm
by Blichew
Hi again,

this time I'll write about small puzzle I've created: wall button that moves in a loop. It can be easily extended by adding a few more buttons that has to be stopped in one line or something...

Unlike my last puzzle (memory-like lever game) this is actually location independent (doesn't matter where you place it, I'm using getWorldPosition before setWorldPosition :) )


0. How it works:
http://youtu.be/-UADODRw-iY

1. Entities:

wall_button - name it dex_button_1
door - name it dex_door
timer - name it dex_timer
floor_trigger - name it dex_trigger
script_entity - name it dex_script

2. Placement:

Image

3. Hooks, connections and Entity-specific settings:

dex_trigger
SpoilerShow
Image
dex_timer
SpoilerShow
Image
dex_button_1
SpoilerShow
Image
4. Script contents:
SpoilerShow

Code: Select all

dex_button_start = dex_button_1:getWorldPosition()
dex_button_1_x = dex_button_start[1]
dex_button_1_y = dex_button_start[2]
dex_button_1_f = dex_button_start[3]-0.0001 
y_moves = {1,0.95,0.9,0.85,0.8,0.75,0.7,0.65,0.6,0.55,0.5,0.45,0.4,0.35,0.3,0.25,0.2,0.15,0.1,0.05,
			0,
			-0.05,-0.1,-0.15,-0.2,-0.25,-0.3,-0.35,-0.4,-0.45,-0.5,-0.55,-0.6,-0.65,-0.7,-0.75,-0.8,-0.85,-0.9,-0.95,-1}
y_index = 21

function dexTick()
	dex_button_1_y = y_moves[y_index]
	if y_index < #y_moves then
		y_index = y_index + 1
	else
		y_index = 1
	end
	dex_button_1:setWorldPosition(dex_button_1_x,dex_button_1_y,dex_button_1_f,0)
end

function dexStop()
	dex_timer.timer:stop()
	dex_button_1.button:disable()
	dex_trigger.floortrigger:disable()
end
I'd create a custom wall model with rail or something that moving button would look more natural but I'm quite dumb when it comes to editting anything in something more complicated than Ms Paint :D

--
Blichew

Re: [Script/puzzle]Moving button (dexterity puzzle)

Posted: Mon Nov 03, 2014 4:43 am
by Eleven Warrior
Now that's a good example how things are done mate, pictures, video and code thxs for this awesome job :)

Re: [Script/puzzle]Moving button (dexterity puzzle)

Posted: Mon Nov 03, 2014 9:24 am
by Drakkan
wooot, that video, fantastic job ! :d Id like to manage this script, hope will find it out.

Re: [Script/puzzle]Moving button (dexterity puzzle)

Posted: Mon Nov 03, 2014 9:45 am
by Blichew
Drakkan wrote:wooot, that video, fantastic job ! :d Id like to manage this script, hope will find it out.

Hah, that's literally the first non-mobile video I've recorded in my life and I'm 30 :P

Re: [Script/puzzle]Moving button (dexterity puzzle)

Posted: Mon Nov 03, 2014 10:21 pm
by Blichew
Bumping for update - I've made a slightly more complicated version: http://youtu.be/LxeXGVZPvZQ :)

Re: [Script/puzzle]Moving button (dexterity puzzle)

Posted: Tue Nov 04, 2014 9:47 am
by Mysterious
Blichew That last video was very cool I love it, good job :)

Re: [Script/puzzle]Moving button (dexterity puzzle)

Posted: Thu Nov 06, 2014 6:32 pm
by Rougecorne
Awesome ! Thank you :D

Re: [Script/puzzle]Moving button (dexterity puzzle)

Posted: Thu Nov 06, 2014 6:50 pm
by Montis
Pretty cool the 2nd one.


Soooo... Button Hero incoming?