SythsGod

computer_altar

Mar 24th, 2020
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. allSlates = {"Blank", "Reinforced", "Imbued", "Demonic", "Ethereal"}
  2.  
  3. -- init
  4. rednet.open("left")
  5.  
  6. function clearTerm()
  7.     term.clear()
  8.     term.setCursorPos(1,1)
  9. end
  10.  
  11. function startCraftingProcess(amount, slate)
  12.     msg = {}
  13.     msg[0] = amount
  14.    
  15.     for i = 1, 5 do
  16.         if string.lower(allSlates[i]) == string.lower(slate) then
  17.             msg[1] = i
  18.         end
  19.     end
  20.    
  21.     clearTerm()
  22.     write("Crafting " .. tostring(amount) .." " .. slate .. " slate(s).")
  23.  
  24.     rednet.broadcast(msg, "bloodaltar")
  25.    
  26.     id, msg = rednet.receive("bloodaltar")
  27.    
  28.     if msg == "success" then
  29.         clearTerm()
  30.         write("Succesfully crafted slates.\n")
  31.         write("Press any key to continue...")
  32.        
  33.         evt, key = os.pullEvent("key")
  34.         evt, key = os.pullEvent("key_up")
  35.     elseif msg == "failure" then
  36.         clearTerm()
  37.         write("Something went wrong... rebooting.")
  38.        
  39.         os.sleep(2.5)
  40.         os.reboot()
  41.     end
  42. end
  43.  
  44. while true do
  45.     clearTerm()
  46.     write("Input slates (For a list type 'list'):\n")
  47.    
  48.     slate = read()
  49.    
  50.     if input == "list" then
  51.         clearTerm()
  52.         write("List of available slates:\n")
  53.        
  54.         x = 5
  55.         y = 2
  56.        
  57.         for i = 1, 5 do
  58.             term.setCursorPos(x,y+i-1)
  59.             write(tostring(allSlates[i]))
  60.         end
  61.        
  62.         term.setCursorPos(1, 7)
  63.                                
  64.         write("\nPress a key to continue..")
  65.         evt, key = os.pullEvent("key")
  66.         evt, key = os.pullEvent("key_up")
  67.     else
  68.         write("Amount: ")
  69.         amount = read()
  70.        
  71.         startCraftingProcess(amount, slate)
  72.     end    
  73. end
  74.  
  75. rednet.close("left")
Add Comment
Please, Sign In to add comment