Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- furnaces=6
- --CHANGE THIS NUMBER TO THE NUMBER OF FURNACES YOU HAVE SETUP
- -------------------
- rf=furnaces
- af={}
- for i=1,rf do
- af[i]=true
- end
- orders={}
- pf={}
- for i=1,rf do
- pf[i]=0
- end
- function ref()
- if turtle.getFuelLevel()<1 then
- slot = turtle.getSelectedSlot()
- turtle.select(1)
- turtle.refuel(1)
- turtle.select(slot)
- end
- end
- function fd()
- if not turtle.forward() then
- ref()
- end
- end
- function bk()
- if not turtle.back() then
- ref()
- end
- end
- function up()
- if not turtle.up() then
- ref()
- end
- end
- function dn()
- if not turtle.down() then
- ref()
- end
- end
- function start()
- shell.run("clear")
- write("Welcome to the ")
- term.setTextColor(colors.red)
- print("FORGE")
- term.setTextColor(colors.white)
- print("Options:")
- print("1: Add an order ("..rf.." furances ready)")
- print("2: Check on an order")
- print("3: Quit")
- end
- function ta() turtle.turnLeft();turtle.turnLeft() end
- function drop()
- up()
- fd()
- turtle.dropDown()
- bk()
- dn()
- end
- function get()
- dn()
- fd()
- turtle.suckUp()
- bk()
- up()
- end
- function nz(num)
- if num<0 then
- return 1
- end
- return num
- end
- function chkstart()
- ta()
- fd()
- dn()
- turtle.turnLeft()
- fd()
- turtle.turnRight()
- turtle.select(2)
- turtle.suckUp()
- for i=1,furnaces-1 do
- fd()
- turtle.suckUp()
- end
- turtle.turnRight()
- fd()
- up()
- up()
- bk()
- turtle.turnRight()
- turtle.select(9)
- turtle.suckDown()
- for i=1,furnaces-1 do
- fd()
- turtle.suckDown()
- end
- turtle.turnLeft()
- fd()
- dn()
- turtle.turnRight()
- fd()
- end
- chkstart()
- while true do
- start()
- e,ch = os.pullEvent()
- if e=="char" then
- ch=tonumber(ch)
- shell.run("clear")
- if ch==3 then break
- elseif ch==1 then
- local anil=false
- local anum=0
- for i=1,furnaces do
- if af[i] then anil=true end
- end
- if not anil then
- print("No open furnaces ATM, check back later")
- read()
- else
- num=0
- for i=2,16 do
- num=num+turtle.getItemCount(i)
- end
- if num==0 then
- print("You need to add an item first")
- read()
- else
- local slots = {}
- for i=2,16 do
- if turtle.getItemCount(i)>0 then table.insert(slots,i) end
- end
- if #slots>1 then
- repeat
- repeat
- shell.run("clear")
- print("More than one item detected, which slot?")
- print("|**|2 |3 |4 |")
- print("|5 |6 |7 |8 |")
- print("|9 |10|11|12|")
- print("|13|14|15|16|")
- a=tonumber(read())
- until tonumber(a)~=nil and a>1 and a<17
- until turtle.getItemCount(a)>0
- else a=slots[1] end
- print("AOK")
- i=0
- repeat i=i+1
- until af[i] or i>#af
- ta()
- j=0
- repeat fd();j=j+1
- until j==i
- turtle.turnLeft()
- --DROP CODE
- turtle.select(a)
- pf[i]=turtle.getItemCount(a)
- drop()
- orders[i]=os.clock()
- af[i]=false
- rf=rf-1
- --END DROP CODE
- turtle.turnLeft()
- j=0
- repeat fd();j=j+1
- until j==i
- end end
- elseif ch==2 then
- local anil=false
- for i=1,furnaces do
- if orders[i]~=nil then anil=true end
- end
- if anil then
- repeat
- shell.run("clear")
- print("Which order:")
- for i=1,furnaces do
- if orders[i]~=nil then
- print(i..": "..pf[i].." items, started "..os.clock()-orders[i].." seconds ago")
- end
- end
- chk = tonumber(read())
- until chk~=nil and chk<furnaces+1
- shell.run("clear")
- print("Order "..chk)
- if orders[chk]==nil then
- print("Has not started yet.")
- else
- -- |===> |
- percent=math.floor(((os.clock()-orders[chk])/(pf[chk]*10)*10))
- if percent < 10 then
- print("|"..string.rep("=",nz(percent))..">"..string.rep(" ",10-nz(percent)).."|")
- print(percent*(10).."% Done")
- else
- print("Is done")
- end
- end
- read()
- else
- print("No running orders.")
- read()
- end
- end
- elseif e=="timer" then
- for i=1,furnaces do
- if orders[i]~=nil then
- if os.clock()-orders[i] >= pf[i]*10 then --Retrieve cooked items
- ta()
- j=0
- repeat fd();j=j+1
- until j==i
- turtle.turnLeft()
- get()
- turtle.turnLeft()
- j=0
- repeat fd();j=j+1
- until j==i
- orders[i]=nil
- pf[i]=0
- af[i]=true
- rf=rf+1
- end
- end
- end
- end
- os.startTimer(1)
- end
- shell.run("clear")
- print("Thanks for using FORGE")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement