Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- me = peripheral.wrap("left")
- c1= peripheral.wrap("top")
- c2= peripheral.wrap("bottom")
- mon = peripheral.wrap("right")
- index=0;
- craftingjobs = {}
- function checkCrafting(item,nbToCraft)
- found =me.findItem(item)
- if(found ~= nil) then
- flag = true
- count=found.getMetadata().count
- for k,v in pairs(craftingjobs) do
- if(item.name == v.item.id and item.damage == v.item.damage) then
- flag= false
- break
- end
- end
- if(count<nbToCraft and flag ) then
- table.insert(craftingjobs,{craft=found.craft(nbToCraft-count),item={id=found.getMetadata().name,damage = found.getMetadata().damage,name=found.getMetadata().displayName,count=nbToCraft-count}})
- end
- end
- end
- local currenthour =-1
- local tickNumbers =0
- function getTime()
- if(currenthour ==-1 or tickNumbers >=600) then
- local c = http.get("http://worldclockapi.com/api/json/utc/now")
- tickNumbers=0
- if(c ~= nil) then
- jsonbj=textutils.unserialiseJSON(c.readAll())
- local s =jsonbj.currentDateTime
- local strc=string.sub(s,string.find(s, "T%d%d"))
- strc =string.sub(strc,string.find(strc, "%d%d"))
- local nb = tonumber(strc)
- currenthour = nb+1
- return currenthour
- end
- end
- tickNumbers=tickNumbers+1
- return currenthour
- end
- while true do
- for k,v in pairs(c1.list()) do
- local count = v.count
- if(v.count ==1) then
- count =64
- end
- checkCrafting(v,count);
- end
- if(getTime() >=19) then
- for k,v in pairs(c2.list()) do
- print(v.count)
- checkCrafting(v,v.count);
- end
- end
- mon.clear()
- mon.setTextScale(0.5)
- if(#craftingjobs >=1) then
- if(index > #craftingjobs) then
- index=1
- end
- mon.setCursorPos(1,1)
- elem = craftingjobs[index];
- if(elem ~= nil) then
- mon.write("Crafting:")
- mon.setCursorPos(1,2)
- mon.write(elem.item.name)
- mon.setCursorPos(1,3)
- mon.write(elem.item.count)
- if(elem.craft.isFinished() == true or elem.craft.isCanceled() == true) then
- table.remove(craftingjobs,index)
- end
- end
- else
- mon.setCursorPos(1,2)
- mon.write("ALL")
- mon.setCursorPos(3,4)
- mon.write("CLEAR")
- end
- index=index+1
- sleep(1)
- end
Add Comment
Please, Sign In to add comment