Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- coalbox=peripheral.wrap("back")
- orebox=peripheral.wrap("top")
- sides={"north","south","west","east"}
- if (fs.exists("choices") == false) then --Check if this is first time run, no saved choices on file
- while true do --Asks for side for attached inventory
- print("Which direction is the back of the computer facing?")
- for i=1, #sides do
- print(i..". "..sides[i])
- end
- local answer = read()
- if tonumber(answer)==nill then
- print("-Wrong answer, input not a number-")
- else
- local answerv = tonumber(string.format("%." .. 0 .. "f", answer))
- if (0 < answerv and answerv <= 4) then
- side1=answerv
- --print("Side ", sides[side1], " chosen")
- break
- else
- print("-Wrong answer, input does not match number of sides-")
- end
- end
- end
- local file = fs.open("choices","w")
- file.writeLine("side1="..tostring(side1))
- file.close()
- end
- os.loadAPI("choices") -- Reads choices from file
- local side1 = choices.side1
- while true do
- --fuel refill
- refueled=false
- nofuel=false
- while refueled==false and nofuel==false do
- for i=1,coalbox.size() do
- if coalbox.getItemMeta(i) ~= nil then
- coalbox.pushItems("up",i,64,2)
- refueled=true
- break
- elseif i==coalbox.size() then
- --print("Fuel box empty")
- nofuel=true
- --print("nofuel true")
- break
- else
- sleep(0.05)
- end
- end
- end
- --load smelting material
- reloaded=false
- noore=false
- output=true
- while reloaded==false and noore==false do
- orebox.pullItems(sides[side1],3,64,orebox.size())
- if orebox.getItemMeta(orebox.size()) == nil then
- output=false
- --print("output false")
- end
- orebox.pushItems("up",orebox.size(),64)
- for i=1,orebox.size()-1 do
- if orebox.getItemMeta(i) ~= nil then
- orebox.pushItems(sides[side1],i,64,1)
- reloaded=true
- break
- elseif i==orebox.size()-1 then
- --print("Ore box empty")
- noore=true
- --print("noore true")
- break
- else
- sleep(0.05)
- end
- end
- end
- if noore==true and output==false then
- print("No ore, sleeping 8s")
- redstone.setOutput("front", true)
- sleep(8)
- elseif nofuel==true and output==false then
- print("No fuel, sleeping 30s")
- redstone.setOutput("front", true)
- sleep(30)
- else
- redstone.setOutput("front", false)
- sleep(1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement