Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- local path = {}
- local count = nil
- local item = nil
- local amount = 0
- local craftingGrid = {1,2,3,5,6,7,9,10,11}
- local ingredients = {}
- local sortTable = {}
- local orderedTable = {}
- function loadTable(num)
- local file = fs.open("RecipeList/"..tArgs[1].."/path"..num,"r")
- local data = file.readAll()
- file.close()
- path[num] = textutils.unserialize(data)
- count = 0
- for i,v in pairs(path[1]) do
- count = count + 1
- end
- end
- function displayTable()
- for i,v in pairs(path) do
- print(i.."\)")
- for k in pairs(path[i]) do
- table.insert(sortTable,k)
- end
- table.sort(sortTable)
- for i2,v2 in ipairs(sortTable) do
- for i3,v3 in pairs(v) do
- if v2==i3 then
- table.insert(orderedTable,i2,v3)
- end
- end
- end
- for i2,v2 in ipairs(orderedTable) do
- for i3,v3 in pairs(v) do
- if v2==v3 then
- if i3 >= 4 then
- i3 = i3 - 1
- end
- if i3 >= 8 then
- i3 = i3 - 1
- end
- print(" "..i3.." - "..v2)
- end
- end
- end
- end
- sortTable = {}
- orderedTable = {}
- end
- function clearInv(n,p)
- local s = 1
- if p == nil then
- p = 1
- elseif math.abs(p)~=p then
- s = n
- n = 1
- end
- for i=s,n,p do
- turtle.select(i)
- turtle.dropDown()
- end
- end
- function buffer(num)
- turtle.select(16)
- ingredient = {}
- while amount~=count and turtle.suck() do
- item = turtle.getItemDetail()
- for i,v in pairs(path[num]) do
- if v == item.name then
- for i2,v2 in pairs(ingredients) do
- if v == v2 then
- turtle.dropDown()
- end
- end
- if turtle.getItemCount() > 0 then
- turtle.transferTo(i,1)
- amount = amount + 1
- table.insert(ingredients,item.name)
- end
- end
- end
- if turtle.getItemCount() > 0 then
- turtle.dropDown()
- end
- end
- end
- function craft()
- if not turtle.craft() then
- textutils.slowPrint("Error: Insufficient Ingredients")
- clearInv(15,-1)
- error()
- else
- if turtle.getSelectedSlot() ~= 16 then
- turtle.select(16)
- end
- turtle.dropUp()
- clearInv(15,-1)
- end
- end
- function run()
- loadTable(1)
- displayTable()
- buffer(1)
- craft()
- end
- run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement