Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Face = "north"
- Nuclear = "front"
- Material = "left"
- Void = "bottom"
- coolingSingel = "right"
- PauseSingel = "back"
- ThickID = 30086
- FuelID = 30101
- ThickWarn = 9980
- FuelWarn = 9980
- TempThresholds = 50
- ThickSlot = {2,3,4,10,14,20,21,22}
- FuelSlot = {11,12,13}
- --=====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
- nust = peripheral.wrap(Nuclear)
- function temp()
- if (nust.getHeat()/nust.getMaxHeat()*100) > TempThresholds then
- return true
- else
- return false
- end
- end
- prs = function(pa)
- redstone.setOutput(coolingSingel,pa)
- end
- sts = function(pa)
- redstone.setOutput(PauseSingel,pa)
- end
- prs(false)
- sts(false)
- --item control
- 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
- sts(false)
- local suc = true
- --clear turtle
- for sei=1,16,1 do
- local co = turtle.getItemCount(sei)
- if co ~= 0 then
- for ty=1,16,1 do
- local suc = voc.put(sei,co)
- if suc then break else os.sleep(0.5) end
- end
- end
- if not suc then break end
- end
- if not suc then print("<!>can not clear Turtle") expection = true return end
- suc = false
- --get item
- for ty=1,6,1 do
- for sei=1,mac.size,1 do
- if mac.info(sei) == itemID then
- suc = mac.take(sei,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
- prs(true)
- suc = false
- --change item
- 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
- voc.put(2,turtle.getItemCount(2))
- 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(not temp())
- if speedUp then
- os.sleep(0.2)
- else
- os.sleep(2)
- end
- end
- end
- --go
- print ("start")
- start()
- print ("stop with a expection")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement