Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --north south east western
- Face = "north"
- --front left right back
- Nuclear = "front"
- Material = "left"
- Void = "back"
- --front left right back top bottom
- coolingSingel = "right"
- PauseSingel = "bottom"
- --number
- ThickID = 30086
- FuelID = 30101
- ThickWarn = 9980
- FuelWarn = 9980
- --maxtri
- ThickSlot = {2,3,10,13,19,22,29,30}
- FuelSlot = {11,12,20,21}
- --=====codes=====
- pos = {"north", "east", "south", "western"}
- dict = {"front", "right", "back", "left"}
- function getPosition(drection,flip)
- if (drection=="top") then
- if flip then
- return "down"
- else
- return "up"
- end
- elseif(drection=="bottom") then
- if flip then
- return "up"
- else
- return "down"
- end
- else
- local ph = 1
- local dh = 1
- for s=1,#pos,1 do
- if pos[s] == Face then
- ph = s
- if flip then ph = ph + 2 end
- break
- end
- end
- for s=1,#dict,1 do
- if dict[s] == drection then
- dh = s + ph -1
- break
- end
- end
- while dh > 4 do
- dh = dh - 4
- end
- return pos[dh]
- end
- end
- function getChest(direct,check)
- if (check ~= peripheral.getType(direct)) then
- return nil,false,peripheral.getType(direct)
- end
- local gd = getPosition(direct,false)
- local gdf = getPosition(direct,true)
- local ch = peripheral.wrap(direct)
- print ("get chest at "..direct..",with pos "..gd..","..peripheral.getType(direct))
- local ct = {
- size = ch.getInventorySize(),
- info = function(index)
- local ti = ch.getStackInSlot(index)
- if ti == nil then
- return 0,0
- else
- return ti.id,ti.dmg
- end
- end,
- put = function(index,count,TurtleIndex)
- local c = 0
- if TurtleIndex ~= nil then
- c = ch.pullItemIntoSlot(gdf,TurtleIndex,count,index)
- else
- c = ch.pullItem(gdf,index,count)
- end
- if c == 0 then
- return false,c
- else
- return true,c
- end
- end,
- take = function(index,count)
- local ful = true
- for si = 1,16,1 do
- if turtle.getItemCount(si) == 0 then
- ful = false
- break
- end
- end
- if ful then
- return false,0
- else
- return true,ch.pushItem(gdf,index,count)
- end
- end
- }
- return ct,true,peripheral.getType(direct)
- end
- nuc,suc = getChest(Nuclear,"nuclear_reactor")
- if not suc then print ("fail") return end
- mac,suc = getChest(Material,"ender_chest")
- if not suc then print ("fail") return end
- voc,suc = getChest(Void,"ender_chest")
- if not suc then print ("fail") return end
- suc = nil
- prs = function(pa)
- redstone.setOutput(coolingSingel,pa)
- end
- sts = function(pa)
- redstone.setOutput(PauseSingel,pa)
- end
- prs(false)
- sts(false)
- local suc = true
- --item control
- function clearTurtle()
- for sei=1,16,1 do
- local co = turtle.getItemCount(sei)
- if co ~= 0 then
- voc.put(sei,co)
- end
- end
- end
- speedUp = false
- expection = false
- function checkItem(itemID,maxdmg,slots)
- for i=1,#slots,1 do
- local d,g = nuc.info(slots[i])
- if d ~= itemID then
- prs(true)
- sts(false)
- clearTurtle()
- local suc = false
- for i=1,8,1 do
- for j=1,mac.size,1 do
- if mac.info(j) == itemID then
- suc = mac.take(j,1)
- if suc then break end
- end
- end
- if suc then break else os.sleep(1) end
- end
- if not suc then print("<!>no item "..itemID) expection = true return end
- for ty=1,8,1 do
- suc = nuc.take(slots[i],1)
- if not suc then break end
- suc = nuc.put(slots[i],1,1)
- if suc then break end
- end
- if not suc then print("<!>change item "..itemID.."failed,at slot "..slots[i]) expection = true return end
- elseif g >= maxdmg then
- speedUp = true
- end
- end
- end
- --main
- function start()
- while true do
- speedUp = false
- checkItem(ThickID,ThickWarn,ThickSlot)
- checkItem(FuelID,FuelWarn,FuelSlot)
- if expection then return end
- prs(false)
- sts(true)
- if speedUp then
- os.sleep(0.25)
- else
- os.sleep(5)
- end
- end
- end
- --go
- print ("start")
- start()
- prs(false)
- print ("stop with a expection")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement