1
Your scripts / Re: Do tasks in a certain order to open a door or whatever
« on: November 05, 2019, 12:50:21 am »
Awesome idea 
I'll mention that this is intended to be a map script in case that is not obvious.
It could be improved by deactivating the puzzle once the player has solved it. This could be done simply by setting switch_index to nil once solved, then checking it at the beginning of the map:process_switch() method:
Also could be useful to save the state of the solved puzzle as a savegame variable so that the player doesn't have to solve it again when revisiting the map later. Simply save the savegame variable once the puzzle is complete:

I'll mention that this is intended to be a map script in case that is not obvious.
It could be improved by deactivating the puzzle once the player has solved it. This could be done simply by setting switch_index to nil once solved, then checking it at the beginning of the map:process_switch() method:
Code: (lua) [Select]
function map:process_switch(name)
if switch_index then --add this line
if switches[switch_index] == name then --unchanged (for context)
--lines in between unchanged
end --unchanged
end --add this line
end
Also could be useful to save the state of the solved puzzle as a savegame variable so that the player doesn't have to solve it again when revisiting the map later. Simply save the savegame variable once the puzzle is complete:
Code: (lua) [Select]
game:set_value("puzzle_complete", true)
Then change the first line of the script to the following:Code: (lua) [Select]
local switch_index = not game:get_value("puzzle_complete") and 1