Puzzles


#1

has anyone tried a puzzle yet?
I’m doing a simple room and I thought why not have a combination lock! a sequencial puzzle is very handy and can be very useful for other things.
I’ve not tried yet and to keep it simple it has only 4 buttons, in Visionaire which uses lua it would look something like this:

[code]function init_keys()
print(‘init_keys’)
max_keys = 4
current_pos = 1
keys = {}
end

function test_key_combination()
print(‘test_key_combination’)
if keys[1] == 1 and keys[2] == 1 and keys[3] == 3 and keys[4] == 2 then
print(‘puzzle solved’)
local action = getObject(“Actions[bolt]”) —calls action bolt
startAction(action)
local cond = getObject(“Conditions[lock_open]”) — changes condition lock_open
cond:setValue(VConditionValue, false)

else
print(‘wrong combination’)
local action = getObject(“Actions[start_puzzle]”) —restarts script
startAction(action)
end
end

function key_pressed(key)
print('key_pressed: ’ … key … ’ at pos ’ … current_pos)
keys[current_pos] = key
current_pos = current_pos + 1
if current_pos > max_keys then
test_key_combination()
end
end
[/code]

then something like:

on the keys

Still rendering the scene and my PC must of heard it was getting replaced because its being a nightmare :?


#2

Yes, modules like these should proliferate like mad!
The challenge is getting it put together in a way that can be ‘dropped’ into other code.