Thor_s_Crafter

terraSteel

Mar 14th, 2016
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.98 KB | None | 0 0
  1. -- Terrasteel-Dropper von Thor_s_Crafter --
  2. -- Version 1.1 --
  3.  
  4. local c = peripheral.find("chest")
  5. local side = "SOUTH"
  6. local sec = 10
  7.  
  8. function input()
  9.     if loadconfig == false then
  10.         term.clear()
  11.         term.setCursorPos(1,1)
  12.         print("Auf welcher Seite befindet sich die 2. Kiste?")
  13.         print("NORTH,EAST,SOUTH,WEST,TOP,BOTTOM")
  14.         print("z.B. EAST = Osten (siehe JorneyMap)")
  15.         write("Eingabe: ")
  16.         eingabe = read()
  17.         if eingabe == "NORTH" or eingabe == "EAST" or eingabe == "SOUTH" or eingabe == "WEST" or eingabe == "TOP" or eingabe == "BOTTOM" then
  18.             side = eingabe
  19.             saveConfig()
  20.         else
  21.             input()
  22.         end
  23.     end
  24.     input2()
  25. end
  26.  
  27. function input2()
  28.     term.clear()
  29.     term.setCursorPos(1,1)
  30.     print("Wieviele Sekunden soll gewartet werden?")
  31.     write("Eingabe: ")
  32.     eingabe2 = read()
  33.     if tonumber(eingabe2) > 0 then
  34.         sec = tonumber(eingabe2)
  35.     else
  36.         input2()
  37.     end
  38. end
  39.  
  40. function loadConfig()
  41.     if not fs.exists("config.txt") then
  42.         return false
  43.     else
  44.         local file = fs.open("config.txt","r")
  45.         tmp = file.readAll()
  46.         print(tmp[1])
  47.         sleep(1)
  48.         side = tmp[1]
  49.         return true
  50.     end
  51. end
  52.  
  53.  
  54.  
  55. function saveConfig(text)
  56.     local file = fs.open("config.txt","w")
  57.     file.writeLine(text)
  58.     file.close()
  59. end
  60.  
  61.  
  62. function dropItems()
  63.     local dias = 0
  64.     local pearls = 0
  65.     local steel = 0
  66.     --term.clear()
  67.     --term.setCursorPos(1,1)
  68.     c.condenseItems()
  69.     items = c.getAllStacks()
  70.     for i=1,#items,1 do
  71.         local tmp = items[i]
  72.         local item = tmp.all()
  73.         if item.raw_name == "item.manadiamond" then
  74.             if dias == 0 then
  75.                 c.pushItemIntoSlot(side,i,1)
  76.                 print("dia")
  77.                 dias = dias + 1
  78.             end
  79.         elseif item.raw_name == "item.manapearl" then
  80.             if pearls == 0 then
  81.                 c.pushItemIntoSlot(side,i,1)
  82.                 print("pearl")
  83.                 pearls = pearls + 1
  84.             end
  85.         elseif item.raw_name == "item.manasteel" then
  86.             if steel == 0 then
  87.                 c.pushItemIntoSlot(side,i,1)
  88.                 print("steel")
  89.                 steel = steel + 1
  90.             end
  91.         end
  92.     end
  93.     sleep(sec)
  94.     term.clear()
  95. end
  96.  
  97.  
  98. while true do
  99.     dropItems()
  100. end
Advertisement
Add Comment
Please, Sign In to add comment