bobmarley12345

ZOO_CodeSoftware

Feb 28th, 2022 (edited)
822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. -- https://pastebin.com/PHEMm13R
  2.  
  3. DRIVE_SIDE = "west"
  4.  
  5. -- Use this table structure for each mob, to simply everything :)
  6. CREEPER = { id = 10, x = -3865, y = 68, z = -4595 }
  7. MAGMA = { id = 10, x = -3863, y = 68, z = -4603 }
  8. SKELETON = { id = 11, x = -3865, y = 68, z = -4605 }
  9.  
  10. function loadRoomIntoKeyCard(mob)
  11.     -- As long as mob follows the table structure at the top, this works
  12.     security.loadSecurityCode(DRIVE_SIDE, mob.id)
  13. end
  14.  
  15. function registerButton(button)
  16.     security.registerButton(button.x, button.y, button.z, button.id)
  17. end
  18.  
  19. function registerButtons()
  20.     registerButton(CREEPER)
  21.     registerButton(MAGMA)
  22.     registerButton(SKELETON)
  23. end
  24.  
  25. function doApp()
  26.     while (true) do
  27.         term.write(">")
  28.         local input = read()
  29.         if (input == "help") then
  30.             print("loadcode   - Loads a code into the keycard in the drive to the left of this PC")
  31.             print("help       - Shows help")
  32.             print("clear      - Clears the screen")
  33.         elseif (input == "loadcode") then
  34.             print("Which mob do you want to load?")
  35.             print("Make sure there's a keycard in the drive!")
  36.             print("Available rooms: creeper, magma")
  37.             local room = string.lower(read())
  38.             if (room == "creeper") then
  39.                 loadRoomIntoKeyCard(CREEPER)
  40.             elseif (room == "magma") then
  41.                 loadRoomIntoKeyCard(MAGMA)
  42.             else
  43.                 print("Unknown room: " .. room)
  44.             end
  45.         elseif (input == "clear") then
  46.             return
  47.         elseif (input == "reboot") then
  48.             print(":(")
  49.             os.sleep(1)
  50.             os.reboot()
  51.         elseif (input == "update") then
  52.             print("TODO: Auto update system, pull from pastebin")
  53.         else
  54.             print("Unknow command: " .. input)
  55.         end
  56.     end
  57. end
  58.  
  59. registerButtons()
  60.  
  61. while (true) do
  62.     term.setCursorPos(1, 1)
  63.     term.setBackgroundColor(colours.black)
  64.     term.setTextColor(colours.white)
  65.     term.clear()
  66.  
  67.     print("Welcome to the Zoo Keycard System v1.0")
  68.     print("By Carrot and Rolcam :-)")
  69.     print("")
  70.     print("Enter a command. type 'help' for a list of commands")
  71.  
  72.     doApp()
  73.  
  74.     os.sleep(1)
  75. end
Add Comment
Please, Sign In to add comment