Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Opens the file for writing out errors.
- outputfile = "manualAttentionNeeded"
- local file = fs.open( outputfile, "w" )
- items_needed_jade = colony.getBuilderResources({x=227, y=69, z=-2291})
- items_needed_ayleen = colony.getBuilderResources({x=220, y=64, z=-2315})
- items_needed_billy = colony.getBuilderResources({x=346, y=64, z=-2305})
- items_needed = {items_needed_jade, items_needed_ayleen, items_needed_billy}
- print("\nCreating missing items...")
- --Loop through each builder
- for i in pairs(items_needed) do
- --Loop through each item needed.
- for index in pairs(items_needed[i]) do
- local item_needed_name = items_needed[i][index]["item"]["name"]
- local item_needed_count = items_needed[i][index]["item"]["count"]
- local item_needed_status = items_needed[i][index]["status"]
- local item_storage_count = refinedstorage.getItem({name = item_needed_name})["count"]
- --Make sure the item is needed by the builder
- if item_needed_status ~= "NOT_NEEDED" then
- if item_storage_count == nil then
- item_storage_count = 0
- end
- --If the item has a crafting recipe and there is not enough already in storage, craft the remainder needed.
- if refinedstorage.hasPattern({name=item_needed_name}) and item_needed_count - item_storage_count > 0 then
- --Write out what item and how many are in storage out of the total needed.
- file.write("\n")
- file.write(textutils.serialize(item_needed_name))
- file.write(" " .. textutils.serialize(item_storage_count) .. "/" .. textutils.serialize(item_needed_count))
- file.write("\nPreparing to create " .. item_needed_count - item_storage_count)
- refinedstorage.scheduleTask({name=item_needed_name}, item_needed_count - item_storage_count)
- end
- if not refinedstorage.hasPattern({name=item_needed_name}) and item_needed_count - item_storage_count > 0 then --Pattern does not exist, and needs to be created manually.
- file.write("\nPattern Needed for " .. item_needed_name)
- end
- end
- end
- end
- print("Waiting 30s for items to finish crafting...")
- sleep(30)
- print("Outputing Items...")
- i = 0
- index = 0
- for i in pairs(items_needed) do
- --Loop through each item needed.
- for index in pairs(items_needed[i]) do
- local item_needed_name = items_needed[i][index]["item"]["name"]
- local item_needed_count = items_needed[i][index]["item"]["count"]
- local item_needed_status = items_needed[i][index]["status"]
- local output_side = nil
- --Calculate Output Side based on building.
- if i == 1 then
- output_side = "up"
- elseif i == 2 then
- output_side = "north"
- elseif i == 3 then
- output_side = "west"
- else
- output_side = "north"
- end
- --Make sure the item is needed by the builder
- if item_needed_status ~= "NOT_NEEDED" then
- --Extract as many of the item as we need, up to the amount available.
- refinedstorage.extractItem({name=item_needed_name}, item_needed_count, output_side)
- end
- end
- end
- print("Please view " .. outputfile .. " for information on missing items.")
- file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement