Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Mob Guestbook
- -- by SukaiPoppuGo
- --
- -- Require mod plethora
- --
- -- Log mobs generated by mob_spawner
- --
- ------------------------------
- -- pause at startup
- print("init")
- sleep(os.clock()<2 and 2 or 0)
- print("run")
- ------------------------------
- -- params
- local mobType = "Zombie"
- local w,h = term.getSize()
- ------------------------------
- -- datas
- settings.load("guestbook")
- local guestbook = settings.get("guestbook",{})
- ------------------------------
- -- display
- local book = window.create(
- term.current(),
- 1,1, w,h-4, true
- )
- local output = window.create(
- term.current(),
- 1,h-4, w,4, true
- )
- local function display()
- local old = term.redirect(book)
- term.setBackgroundColor(colors.white)
- term.setCursorPos(1,1)
- term.clear()
- for id,date in pairs(guestbook) do
- term.setTextColor(colors.gray)
- print(id)
- term.setTextColor(colors.black)
- print(date)
- term.setTextColour(colors.lightGray)
- print(" "..string.rep("-",w-2))
- end
- term.redirect(old)
- end
- ------------------------------
- -- peripherals
- local p = peripheral.wrap("right")
- local function scan()
- for i,mob in ipairs(p.sense()) do
- if mob.name == mobType
- and not guestbook[mob.id]
- and mob.y == 0
- and mob.x >= 1 and mob.x <= 2
- and mob.z >= 1 and mob.z <= 2
- then
- local old = term.redirect(output)
- term.setTextColor(colors.lightGray)
- print("New mob", mob.name, mob.displayName)
- print(mob.id)
- term.redirect(old)
- guestbook[mob.id] = string.format("day %s, at %s", os.day(), os.time())
- settings.set("guestbook", guestbook)
- settings.save("guestbook")
- end
- end
- end
- ------------------------------
- -- Main
- repeat
- scan()
- display()
- book.redraw()
- output.redraw()
- sleep(20)
- until false
Advertisement
Add Comment
Please, Sign In to add comment