Shnupbups

ComputerCraft rs2 API

Dec 17th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.07 KB | None | 0 0
  1. local function toboolean(a)
  2.   if a == "true" or a == "1" or a == 1 then
  3.     b = true
  4.     return b
  5.   elseif a == "false" or a == "0" or a == 0 then
  6.     b = false
  7.     return b
  8.   else
  9.     return "notbool"
  10.   end
  11. end
  12. function emmit(side,bool,time)
  13.   bool = tostring(bool)
  14.   boolean = toboolean(bool)
  15.   if boolean == "notbool" then
  16.     error(bool.." is not a boolean")
  17.   else
  18.     if boolean == true then
  19.       otherbool = false
  20.     else
  21.       otherbool = true
  22.     end
  23.     rs.setOutput(side,boolean)
  24.     if time then
  25.       time = tonumber(time)
  26.       sleep(time)
  27.       rs.setOutput(side,otherbool)
  28.     end
  29.   end
  30. end
  31. function passEmmit(side,bool,time,pass,cormess,falmess)
  32.   write("Password: ")
  33.   input = read("*")
  34.   if input == pass then
  35.     if cormess then
  36.       x,y = term.getCursorPos()
  37.       y = y + 1
  38.       term.setCursorPos(1,y)
  39.       print(cormess)
  40.     end
  41.     emmit(side,bool,time)
  42.   else
  43.     if falmess then
  44.       x,y = term.getCursorPos()
  45.       y = y + 1
  46.       term.setCursorPos(1,y)
  47.       print(falmess)
  48.     end
  49.     return false
  50.   end
  51. end
Advertisement
Add Comment
Please, Sign In to add comment