Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- i=peripheral.wrap("right")
- turtle.select(16)
- side=4
- pathLength=5
- recipeList={
- 5,
- 17,0,0,
- 0,0,0,
- 0,0,0,
- 280,
- 5,0,0,
- 5,0,0,
- 0,0,0,
- 54,
- 5,5,5,
- 5,0,5,
- 5,5,5,
- 61,
- 4,4,4,
- 4,0,4,
- 4,4,4,
- 4056,
- 0,280,0,
- 280,0,280,
- 0,280,0,
- 4057,
- 0,4,0,
- 4,4056,4,
- 0,4,0,
- 33,
- 5,5,5,
- 4,265,4,
- 4,331,4
- }
- function getItem(id,amount)
- gotItem=false
- x=0
- while gotItem==false and x<=pathLength do
- turtle.placeDown()
- s=peripheral.wrap("bottom")
- if s.list(side)~=nil then
- if s.list(side)[id]~=nil then
- if s.list(side)[id]>=amount then
- s.extract(side,id,1,amount)
- gotItem=true
- else
- if s.list(side)[id]>0 then
- amount=amount-s.list(side)[id]
- s.extract(side,id,1,s.list(side)[id])
- end
- end
- end
- end
- x=x+1
- turtle.digDown()
- turtle.back()
- end
- while x>=1 do
- turtle.forward()
- x=x-1
- end
- end
- function craftItem(id,amount)
- recipe=1
- dumb()
- turtle.select(16)
- while recipeList[recipe]~=id and recipeList[recipe]~=nil do
- recipe=recipe+10
- end
- if recipeList[recipe]~=id then
- gotRecipe=false
- else
- gotRecipe=true
- craftProcess=0
- while craftProcess<9 do
- if recipeList[recipe+craftProcess+1]~=0 then
- getItem(recipeList[recipe+craftProcess+1],amount)
- end
- if gotItem==false then
- print("crafte"..recipeList[recipe+craftProcess+1])
- craftItem(recipeList[recipe+craftProcess+1],1)
- dumb()
- else
- turtle.select(1)
- i.dropUp(craftProcess,amount)
- turtle.select(16)
- craftProcess=craftProcess+1
- end
- end
- end
- if gotItem==true then
- c=peripheral.wrap("top")
- c.setPattern(0,1,2,3,4,5,6,7,8)
- amount2=amount
- while amount2>=0 do
- c.craft(17)
- amount2=amount2-1
- end
- turtle.suckUp()
- end
- end
- function dumb()
- x=1
- while x<=9 do
- turtle.suckUp()
- x=x+1
- end
- x=1
- while x<=15 do
- turtle.select(x)
- turtle.drop()
- x=x+1
- end
- turtle.select(16)
- end
- --Terminal
- while true do
- print("[ecco-Storage-System]")
- command=io.read()
- --Funktions Aufrufe
- if string.sub(command,1,3)=="get" then
- id=string.sub(command,5,string.find(command,",")-1) id=tonumber(id)
- amount=string.sub(command,string.find(command,",")+1) id=tonumber(id) amount=amount+0
- getItem(id,amount)
- if gotItem==false then print("Nicht genug von "..id.." vorhanden") end
- if gotItem==true then print(id.." vorhanden") end
- end
- if string.sub(command,1,5)=="craft" then
- id=string.sub(command,7,string.find(command,",")-1) id=tonumber(id)
- amount=string.sub(command,string.find(command,",")+1) id=tonumber(id) amount=amount+0
- craftItem(id,amount)
- if gotItem==false then print("Nicht genug Items vorhanden") end
- if gotItem==true then print(id.." wurde gecraftet") end
- if gotRecipe==false then print("Kein Rezept für "..id.." gefunden") end
- end
- if string.sub(command,1,4)=="dumb" then
- dumb()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement