Advertisement
sethxi

Hidden Door Opener Server

Apr 13th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.80 KB | None | 0 0
  1. local side = "left"
  2. local rsSide = "right"
  3.  
  4. os.pullEvent = os.pullEventRaw
  5.  
  6. function hash(str)
  7.   local s = 0
  8.   local p = ""
  9.  
  10.   for c in str:gmatch(".") do
  11.       s = s + string.byte(c)
  12.   end
  13.  
  14.   s = bit.bxor(65432895, s)
  15.  
  16.   while s > 0 do
  17.       p = p .. string.char(s % 94 + 33)
  18.       s = bit.brshift(s, 1)
  19.   end
  20.  
  21.   return string.sub(p, 1, p:len() - 1)
  22. end
  23.  
  24. rednet.open(side)
  25.  
  26. term.clear()
  27. term.setCursorPos(1, 1)
  28.  
  29. term.setTextColor(colors.blue)
  30.  
  31. term.write("Hidden Door opener running on " .. side)
  32.  
  33. while true do
  34.   id, msg = rednet.receive()
  35.  
  36.   if not string.sub(msg, 1, 3) == "hd:" then return end
  37.  
  38.   if hash(string.sub(msg, 4, string.len(msg))) == "~08[mvK6+Ujty|N7[>^?_@0($" then
  39.     rs.setOutput(rsSide, true)
  40.     sleep(3)
  41.     rs.setOutput(rsSide, false)
  42.   end
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement