Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Wrap the Blood Altar
  2. a=peripheral.wrap("left")
  3.  
  4. -- Update this depending on what direction you have a chest(s) against your altar, valid directions are "north", "south", "east", "west"
  5. -- This is the direction of the 'pull' chest where the stone is supplied
  6. pullDir = "east"
  7. -- This is the direction of the 'push' chest, where the created slates will be stored.
  8. pushDir = "south"
  9.  
  10. -- Declare id numbers for the different slates for the computer to compare to.
  11. ids = {...}
  12. ids["Basic"] = 4945
  13. ids["Reinforced"] = 4946
  14. ids["Imbued"] = 4997
  15. ids["Demonic"] = 4998
  16. ids["Stone"] = 1
  17.  
  18. -- This function handles creating the slates once things are verified
  19. local function slate(dest,amt)
  20.     for i=1,amt do
  21.         count = amt + 1 - i
  22.         term.clear()
  23.         term.setCursorPos(1,1)
  24.         print("Number of ", dest," Slates left to make: ",count)
  25.         pullIt(pullDir)
  26.         item = a.getStackInSlot(1)
  27.         while item["id"] == nil do
  28.             pullIt(pullDir)
  29.             item = a.getStackInSlot(1)
  30.         end
  31.         id=item["id"]
  32.         while id ~= ids[dest] do
  33.             os.sleep(1)
  34.             item = a.getStackInSlot(1)
  35.             while item == nil do
  36.                 pullIt(pullDir)
  37.                 item = a.getStackInSlot(1)
  38.             end
  39.             id = item["id"]
  40.         end
  41.         pushIt(pushDir)
  42.     end
  43. end
  44.  
  45. -- The function that will pull items from the certain chest, allows for a chest size of up to 108 slots.  Will cycle through the slots till it finds an item to pull into the altar.
  46. function pullIt(pullDir)
  47.     item = a.getStackInSlot(1)
  48.     p = 1
  49.     while item["id"] == nil do
  50.         a.pullItem(pullDir,p,1)
  51.         p = p + 1
  52.         if p > 108 then
  53.             p = 1
  54.         end
  55.         item = a.getStackInSlot(1)
  56.     end
  57. end
  58.  
  59. -- The function that will push items into a certain chest, allows for a chest size of up to 108 slots.  Will cycle through the slots till it finds a slot to push into the chest.
  60. function pushIt(pushDir)
  61.     c = 1
  62.     while not a.pushItem(pushDir,c) do
  63.         c = c + 1
  64.         if c > 108 then
  65.             c = 1
  66.         end
  67.     end
  68. end
  69.  
  70. -- Function that will request the number of items to make then pass through to create the slates once a valid number has been entered.
  71. local function amount(dest)
  72.     rNum = "a"
  73.     while rNum ~= tonumber(rNum) do
  74.         term.clear()
  75.         term.setCursorPos(1,1)
  76.         print("Please enter the amount of ",dest," Slates to make")
  77.         print("Enter 'exit' to return")
  78.         print("-----------------------------------------")
  79.         rNum = read()
  80.         if rNum == "exit" then
  81.             return
  82.         end
  83.  
  84.         if tonumber(rNum) == nil then
  85.             print("Invalid Entry")
  86.             sleep(1)
  87.         elseif tonumber(rNum) > 0 then
  88.             slate(dest,rNum)
  89.             return
  90.         else
  91.             print("Invalid Number")
  92.             sleep(1)
  93.         end
  94.     end
  95. end
  96.  
  97. -- Main function that will run until q is pressed, certain key presses will go for different slates.
  98. while true do
  99.     term.clear()
  100.     term.setCursorPos(1,1)
  101.     print("Welcome to the Advanced Blood Altar Slate Maker")
  102.     print("-----------------------------------------------")
  103.     print(" Press Q to quit")
  104.     print(" Press B to create Basic Slates")
  105.     print(" Press R to create Reinforced Slates")
  106.     print(" Press I to create Imbued Slates")
  107.     print(" Press D to create Demonic Slates")
  108.  
  109.     local e, p1, x, y = os.pullEvent()
  110.     -- If we receive a Q key then we quit (like we said we would)
  111.         if e == "key" then
  112.             os.pullEvent("char")
  113.             if p1 == keys.q then return
  114.  
  115.             elseif p1 == keys.b then
  116.             dest = "Basic"
  117.             amount(dest)
  118.         elseif p1 == keys.r then
  119.             dest = "Reinforced"
  120.             amount(dest)
  121.         elseif p1 == keys.i then
  122.             dest = "Imbued"
  123.             amount(dest)
  124.         elseif p1 == keys.d then
  125.             dest = "Demonic"
  126.             amount(dest)
  127.         else
  128.             print("Invalid Keypress")
  129.             sleep(3)
  130.         end
  131.     end
  132. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement