Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Botania Altar Automation with Logistic piper
- --
- -- Turtle has
- -- an open crate in front
- -- vacuum chest below (auto extract to LP network)
- -- work chest above
- -- orderer/request pipe on the back
- -- analog redstone input from altar comparator on the right
- -- left side free
- --
- -- Turtle job is to keep stock of items that it knows how to manufacture
- -- This particular turtle knows how to manufacture using Botania Altar only
- -- If item ca
- -- Manufacture may be external (output at the front) list is as follows:
- Stock = {}
- Stock["minecraft:pick"] = {keep=10, --actual=0,
- BOM = {{"plank",3,grid={1,2,3}}, {"stick",2,grid={5,8}}}}
- Stock["RuneOfWater"] = {keep=10, --actual=0,
- BOM = {{"manasteel", 1},{"manadust",1},{"bonemeal",1},
- {"Fishingrod",1,ns=true},{"manastone",1,end=true}}}
- Parts = {} -- unique parts that are needed for all the recipes
- for i,v in pairs(Stock) do
- Stock[i].actual = 0
- for j,k in pairs(Stock[i].BOM) do
- Parts[k[1]] = {id=nil, actual=0}
- end
- end
- --grid - where to put items in crafting grid
- --ns -nonstacking item, will store extra in work chest and craft one by one
- --end -item will be consumed at the end of crafting process
- lp = peripheral.wrap("back")
- --[
- local function easyRequest( itemID, amount )
- local result = lp.getLP().getItemIdentifierBuilder()
- result.setItemID( itemID )
- lp.makeRequest( result.build(), amount )
- end
- easyRequest( "minecraft:stone", 1 )
- --]
- while true do
- sleep(10)
- Items = lp.getAvailableItems()
- for k,v in pairs(Items) do
- id=v.getValue1()
- -- f.write("ID: "..id.getId().."\n")
- -- f.write("Unlocalized Name: "..id.getName().."\n")
- -- f.write("Mod Name: "..id.getModName().."\n")
- -- f.write("Meta: "..id.getData().."/"..id.getUndamaged().getData().."\n")
- -- f.write("Count: "..m.getItemAmount(id).."\n\n")
- if Stock[id.getId()] then
- Stock[id.getId()].actual= lp.getItemAmount(id)
- for i,p in pairs(Parts) do
- if like(i,Stock[id.getId()]) then
- amount=lp.getItemAmount(id)
- if Parts[i].actual < amount then --chose the item we have the most of
- Parts[i].id=id
- Parts[i].actual=lp.getItemAmount(id)
- end
- end
- end
- end
- --Now our stock is updated with actual values and all parts needed for crafting also have
- -- first we need to try to make stuff that we have the least of
- for k,v in pairs(Stock) do
- end
- for k,v in pairs(Items) do
- local id=v.getValue1()
- local amt=m.getItemAmount(id)
- if checkCount and amt<=itemThreshold then
- Count=request(id,amt,Count)
- end
- -- it has EVERY item in the network.
- for i=1,#nameList do
- if nameWhitelist and id.getName()==nameList[i] then
- Count=request(id,amt,Count)
- elseif not nameWhitelist and id.getName()~=nameList[i] then
- Count=request(id,amt,Count)
- end
- end
- for i=1,#idList do
- findColon,findColonEnd=string.find(idList[i],":")
- if findColon then
- if idWhitelist and id.getId()==string.sub(idList[i],1,findColon-1) and id.getData()==string.sub(idList[i],findColon+1) then
- Count=request(id,amt,Count)
- elseif not idWhitelist and id.getId()~=idList[i] then
- Count=request(id,amt,Count)
- end
- else
- if idWhitelist and id.getId()==idList[i] then
- Count=request(id,amt,Count)
- elseif not idWhitelist and id.getId()~=idList[i] then
- Count=request(id,amt,Count)
- end
- end
- end
- for i=1,#modList do
- if modWhitelist and id.getModName()==modList[i] then
- Count=request(id,amt,Count)
- elseif not modWhitelist and id.getModName()~=modList[i] then
- Count=request(id,amt,Count)
- end
- end
- if checkDurability and id.isDamageable() and id.getData()/id.getUndamaged().getData()<=durabilityPercentThreshold/100 then
- Count=request(id,amt,Count)
- end
- if k%itemsPerTick==0 then
- searchTime=searchTime+.05
- sleep(0.05)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement