Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trash = peripheral.wrap("left")
- chest = peripheral.wrap("right")
- pipe = peripheral.wrap("right")
- local function isempty(s)
- return s == nil or s == ''
- end
- function sortPlant(plant_id)
- while true do
- chest.getAvailableItems()
- e, result = os.pullEvent("available_items_return")
- for count, item in pairs(result) do
- local id = pipe.getItemID(v[1])
- if id == 30126 then
- local iid = item[1]
- local nbt = pipe.getNBTTagCompound(iid)
- if (nbt["value"]["id"]["value"] == plant_id) then
- print("send to chest!")
- chest.makeRequest(iid,1)
- else
- print("send to trash!")
- trash.makeRequest(iid,1)
- end
- end
- end
- end
- end
- function sortPlantAfterValues(plant_id, result)
- for count, item in pairs(result) do
- sleep(.2)
- local id = pipe.getItemID(item[1])
- local iid = item[1]
- local nbt = pipe.getNBTTagCompound(iid)
- if id == 30126 then
- if (nbt["value"]["id"]["value"] == plant_id) then
- local gr = nbt["value"]["growth"]["value"]
- local ga = nbt["value"]["gain"]["value"]
- local re = nbt["value"]["resistance"]["value"]
- if gr > 20 and gr < 24 then
- if ga > 30 then
- if re < 10 then
- print("Growth: " .. gr .. " Gain: " .. ga .. " Res.: " .. re .. " --- send to chest!")
- chest.makeRequest(iid,1)
- else
- print("Growth: " .. gr .. " Gain: " .. ga .. " Res.: " .. re .. " --- trash!")
- trash.makeRequest(iid,1)
- end
- else
- print("Growth: " .. gr .. " Gain: " .. ga .. " Res.: " .. re .. " --- trash!")
- trash.makeRequest(iid,1)
- end
- else
- print("Growth: " .. gr .. " Gain: " .. ga .. " Res.: " .. re .. " --- trash!")
- trash.makeRequest(iid,1)
- end
- end
- end
- end
- print("Task complete")
- end
- while true do
- chest.getAvailableItems()
- e, result = os.pullEvent("available_items_return")
- sortPlantAfterValues(11, result)
- print("wait 60 sec. and start again")
- sleep(60)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement