Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local test = os.getComputerID() == 26
- local spawner = test and {x=-715,y=58,z=598} or {x=-586,y=13,z=132}
- local drive = peripheral.wrap(test and "drive_1" or "drive_148")
- local dataDir = drive.getMountPath().."/"
- local mon = peripheral.wrap(test and "monitor_9" or "monitor_220")
- local display = peripheral.wrap(test and "monitor_7" or "monitor_206")
- local w,h = mon.getSize()
- local _w,_h = term.getSize()
- local wi = peripheral.find("WorldInterface")
- local ed = peripheral.find("EntityDetector")
- local function getBlockInfos(_x,_y,_z)
- if wi.getBlockDatatags then
- return wi.getBlockDatatags(_x,_y,_z)
- else
- return wi.getBlockInfos(_x,_y,_z)
- end
- end
- local function getEntityList(_r,_x,_y,_z)
- if ed.getEntityListAdvanced then
- return ed.getEntityListAdvanced(_r,_x,_y,_z)
- else
- return ed.getEntityList(_r,_x,_y,_z)
- end
- end
- local function output(line,str)
- term.setCursorPos(1,line)
- term.clearLine()
- term.write(str)
- end
- local function strTime(sec)
- sec = sec or os.clock()
- local str,d,h,m,s=""
- d=math.floor(sec/86400)
- h=math.floor(sec/3600)%24
- m=math.floor(sec/60)%60
- s=math.floor(sec%60)
- if d>0 then str = d>1 and d.." days " or "1 day " end
- if h>0 then str = str..h.."h" end
- if m>0 then str = str..(m>9 and m or "0"..m) end
- if h==0 then str = m>0 and str..":"..(s>9 and s or "0"..s) or s.."s" end
- return str
- end
- local function header()
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- output(1,"#"..os.getComputerID().." - "..os.getComputerLabel())
- output(2,"Running: "..strTime())
- term.setBackgroundColor(colors.black)
- term.setTextColour(colors.gray)
- output(3,string.rep(string.char(131),_w))
- term.setTextColor(colors.white)
- end
- term.clear()
- header()
- term.redirect(mon)
- local function getSpawnerDelay()
- local s = getBlockInfos(spawner.x,spawner.y,spawner.z)
- return s.datatags.Delay
- end
- local function displayLog(_x,_y,str)
- display.setCursorPos(_x,_y)
- display.setBackgroundColor(colors.black)
- display.setTextColor(colors.white)
- display.write(str)
- end
- displayLog(9,1," ")
- displayLog(14,2," ")
- displayLog(10,3," ")
- displayLog(14,4," ")
- displayLog(10,5," ")
- local total = 0
- local batch = 0
- local prevDelay = 10000
- local tick = os.startTimer(.1)
- term.clear()
- term.setCursorPos(1,h-1)
- print("start")
- while true do
- local delay = getSpawnerDelay()
- displayLog(9,1,strTime(math.floor((delay/20)+.5)).." ")
- if prevDelay < delay then
- batch = batch+1
- displayLog(14,2,math.floor(batch).." ")
- local batchNo = "-"..batch.."-"
- local padL = string.rep(" ",math.floor((w-string.len(batchNo))/2))
- local padR = string.rep(" ",math.ceil((w-string.len(batchNo))/2))
- term.setBackgroundColor(colors.gray)
- term.write(padL..batchNo..padR)
- term.setBackgroundColor(colors.black)
- print()
- sleep(.2)
- --Scan mobs
- local mobCount = {
- zombie=0,
- villager=0,
- baby=0,
- }
- local mobs = getEntityList(7,spawner.x+.5,spawner.y-1.5,spawner.z+.5)
- if #mobs>0 then
- local count,i,mob=0
- for i,mob in pairs(mobs) do
- if mob.name=="Zombie" then
- count = count+1
- local kind = ""
- local file = "zombie"
- if mob.datatags.IsChickenJockey then
- kind = "chickenJockey"
- file = file.."_chickenJockey"
- mobCount.baby=mobCount.baby+1
- elseif mob.datatags.IsBaby then
- kind = "baby "
- file = file.."_baby"
- mobCount.baby=mobCount.baby+1
- end
- if mob.datatags.IsVillager then
- kind = kind.."villager "
- file = file.."_villager"
- mobCount.villager=mobCount.villager+1
- end
- if not fs.exists(dataDir..file) then
- local fh = fs.open(dataDir..file,"w")
- fh.write(textutils.serialise(mob))
- fh.close()
- end
- if kind == "" then
- kind = "zombie"
- mobCount.zombie=mobCount.zombie+1
- end
- print(kind)
- end
- end
- displayLog(10,3,math.floor(mobCount.zombie).." ")
- displayLog(14,4,math.floor(mobCount.villager).." ")
- displayLog(10,5,math.floor(mobCount.baby).." ")
- local x,y = term.getCursorPos()
- total = total + count
- term.setCursorPos(1,h)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.clearLine()
- term.write("Total: "..total)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(x,y)
- end
- end
- prevDelay = delay
- tick = os.startTimer(1)
- e = os.pullEventRaw()
- if e=="terminate" then
- term.redirect(term.native())
- term.setCursorPos(1,5)
- print("/log - "..string.char(169).." SukaiPoppuGo")
- error("Terminated",0)
- return
- elseif e=="timer" then
- term.redirect(term.native())
- header()
- term.redirect(mon)
- end
- end
Add Comment
Please, Sign In to add comment