Legend of Grimrock 2

Legend of Grimrock 2

View Stats:
Old Man River Mar 23, 2018 @ 12:04am
Reset button for Push Block puzzle in editor
Hey so I'm just getting into scripting and I only have the very basic of knowledge on it, was using Grimrock.net for help but the site's been down all day.

So long story short question is can anyone tell me the script I need for making a reset switch work with pushable blocks like they do in the base game? Thanks in advance.
< >
Showing 1-3 of 3 comments
Doryann34 Mar 26, 2018 @ 2:17pm 
Hi Jason!

I'm not sure this is the perfect solution, but here is how I managed to create pushable block puzzles' buttons:

1. Place a wall button in your room

2. Connect this button with all "pushable block floors" and "pushable block floor triggers" of your puzzle (= 1 "onActivate" hook per floor tile)

3. Create a lua script entity

4. In the code field of the script entity, copy-paste this:

function Reset()
spawn("teleportation_effect",party.level,party.x,party.y,0,0)
pushable_block_1:destroy()
pushable_block_2:destroy()
pushable_block_3:destroy()
pushable_block_4:destroy()
do this for each pushable block your puzzle has
spawn("pushable_block",LEVEL,X,Y,0,0,"pushable_block_1")
spawn("pushable_block",LEVEL,X,Y,0,0,"pushable_block_2")
spawn("pushable_block",LEVEL,X,Y,0,0,"pushable_block_3")
spawn("pushable_block",LEVEL,X,Y,0,0,"pushable_block_4")
you now need to re-create every pushable blocks you just destroyed.
Make sure to replace the LEVEL / X / Y terms with the correct coordinates of the blocks in your puzzle
end

5. Connect the button with the script entity you just created (onActivate => call "Reset" function)

I hope it works for you.
cheers
Doryann
Doryann34 Mar 26, 2018 @ 2:23pm 
And before you ask: yes it is necessary to destroy and recreate each block. It may sound useless, since the game has a "setPosition" function. But moving back the original blocks in their initial position, will only result in a mess. Trust me, I've tried that before and the puzzle will then freeze when touching the blocks again.
Last edited by Doryann34; Mar 26, 2018 @ 2:24pm
Old Man River Mar 26, 2018 @ 6:56pm 
Originally posted by ydaujeard:
Hi Jason!

I'm not sure this is the perfect solution, but here is how I managed to create pushable block puzzles' buttons:

1. Place a wall button in your room

2. Connect this button with all "pushable block floors" and "pushable block floor triggers" of your puzzle (= 1 "onActivate" hook per floor tile)

3. Create a lua script entity

4. In the code field of the script entity, copy-paste this:

function Reset()
spawn("teleportation_effect",party.level,party.x,party.y,0,0)
pushable_block_1:destroy()
pushable_block_2:destroy()
pushable_block_3:destroy()
pushable_block_4:destroy()
do this for each pushable block your puzzle has
spawn("pushable_block",LEVEL,X,Y,0,0,"pushable_block_1")
spawn("pushable_block",LEVEL,X,Y,0,0,"pushable_block_2")
spawn("pushable_block",LEVEL,X,Y,0,0,"pushable_block_3")
spawn("pushable_block",LEVEL,X,Y,0,0,"pushable_block_4")
you now need to re-create every pushable blocks you just destroyed.
Make sure to replace the LEVEL / X / Y terms with the correct coordinates of the blocks in your puzzle
end

5. Connect the button with the script entity you just created (onActivate => call "Reset" function)

I hope it works for you.
cheers
Doryann

I'll give it a try, thank you for your help :)
< >
Showing 1-3 of 3 comments
Per page: 1530 50

Date Posted: Mar 23, 2018 @ 12:04am
Posts: 3