Advertisement
cr34m3

BookPuzzleMBMA

Mar 10th, 2014
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.73 KB | None | 0 0
  1. --[[
  2.  BookPuzzle.lua
  3.     Functions for bookcase puzzle
  4. --]]
  5.  
  6. bookssolved = getObject("Conditions[FoundSecretRoom]")
  7. feedback = getObject("Values[PuzzleFeedback]")
  8. allin = getObject("Conditions[B10Inserted]")
  9. tblOuts = {}
  10. tblOuts[1] = getObject("Conditions[B1Out]")
  11. tblOuts[2] = getObject("Conditions[B2Out]")
  12. tblOuts[3] = getObject("Conditions[B3Out]")
  13. tblOuts[4] = getObject("Conditions[B4Out]")
  14. tblOuts[5] = getObject("Conditions[B5Out]")
  15. tblOuts[6] = getObject("Conditions[B6Out]")
  16. tblOuts[7] = getObject("Conditions[B7Out]")
  17. tblOuts[8] = getObject("Conditions[B8Out]")
  18. tblOuts[9] = getObject("Conditions[B9Out]")
  19. tblOuts[10] = getObject("Conditions[B10Out]")
  20. booksol = "12345678910"
  21. currentrun = {}
  22.  
  23.  
  24. function ResetBooks()
  25. for x=1,10 do
  26.     tblOuts[x]:setValue(VConditionValue,false)  -- all books back in
  27.     currentrun = {}
  28.     feedback:setValue(VValueString,"Back to where we started...")
  29. end
  30. end
  31.  
  32. function ClickBook(book)
  33. feedback:setValue(VValueString,"")
  34. if tblOuts[book]:getBool(VConditionValue) then  -- reset all on push back
  35.     ResetBooks()
  36. else
  37.     tblOuts[book]:setValue(VConditionValue,true)
  38.     currentrun[#currentrun+1] = book
  39. end
  40. -- check for puzzle completion
  41. if #currentrun==9 and allin:getBool(VConditionValue)==false then
  42.     ResetBooks()
  43.     feedback:setValue(VValueString,"Hmmm... something is still missing.")
  44. elseif #currentrun==10 and allin:getBool(VConditionValue)==true then
  45.     currentsol = ""
  46.     for x=1,10 do
  47.         currentsol = currentsol..currentrun[x]
  48.     end
  49.     if currentsol==booksol then
  50.         feedback:setValue(VValueString,"That must be right. Something is happening.")
  51.         bookssolved:setValue(VConditionValue,true)
  52.     else
  53.         ResetBooks()
  54.         feedback:setValue(VValueString,"Hmmm... I guess that wasn't correct.")
  55.     end
  56. end
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement