[Script/puzzle]Moving button (dexterity puzzle)
Posted: Sun Nov 02, 2014 11:52 pm
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:

3. Hooks, connections and Entity-specific settings:
dex_trigger
dex_timer
dex_button_1
4. Script contents:
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 
--
Blichew
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:

3. Hooks, connections and Entity-specific settings:
dex_trigger
SpoilerShow

SpoilerShow

SpoilerShow

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

--
Blichew