Advertisement
Guest User

chest.lua

a guest
Jun 19th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.54 KB | None | 0 0
  1. -- Chest tampering detection system
  2. -- 620eb42a98a955e79717d0f12d009c94a790d5b7
  3.  
  4. local side = "left"
  5.  
  6. local chest = peripheral.wrap(side)
  7.  
  8. while true do
  9.   local s = textutils.serialize(chest.list())
  10.   local evt = os.pullEvent()
  11.   if evt == "redstone" then
  12.     if rs.getInput(side) then
  13.       print("Chest opened")
  14.       repeat sleep(0.5) until not rs.getInput(side)
  15.       if s == textutils.serialize(chest.list()) then
  16.         print("Chest closed, no items taken")
  17.       else
  18.         print("Chest tampered")
  19.       end
  20.     end
  21.   end
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement