[Script/puzzle]Moving button (dexterity puzzle)

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!
Post Reply
User avatar
Blichew
Posts: 157
Joined: Thu Sep 27, 2012 12:39 am

[Script/puzzle]Moving button (dexterity puzzle)

Post 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
User avatar
Eleven Warrior
Posts: 744
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

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

Post by Eleven Warrior »

Now that's a good example how things are done mate, pictures, video and code thxs for this awesome job :)
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

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

Post by Drakkan »

wooot, that video, fantastic job ! :d Id like to manage this script, hope will find it out.
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
Blichew
Posts: 157
Joined: Thu Sep 27, 2012 12:39 am

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

Post 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
User avatar
Blichew
Posts: 157
Joined: Thu Sep 27, 2012 12:39 am

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

Post by Blichew »

Bumping for update - I've made a slightly more complicated version: http://youtu.be/LxeXGVZPvZQ :)
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

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

Post by Mysterious »

Blichew That last video was very cool I love it, good job :)
User avatar
Rougecorne
Posts: 34
Joined: Wed Oct 29, 2014 1:52 am

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

Post by Rougecorne »

Awesome ! Thank you :D
User avatar
Montis
Posts: 340
Joined: Sun Apr 15, 2012 1:25 am
Location: Grimrock II 2nd playthrough (hard/oldschool)

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

Post by Montis »

Pretty cool the 2nd one.


Soooo... Button Hero incoming?
When destiny calls, the chosen have no choice.

My completed dungeon (LoG1): Hypercube
Post Reply