Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local m = peripheral.find("modem") -- Requires advanced pocket computer w/ modem
- m.open(42) -- Customize to your liking
- local _getSize = term.getSize
- local _setCursorPos = term.setCursorPos
- local _getCursorPos = term.getCursorPos
- -- Override cursor related functions so we have the first line all to ourselves
- term.getSize = function()
- local w, h = _getSize()
- return w, h-1
- end
- term.setCursorPos = function(x, y)
- return _setCursorPos(x, y + 1)
- end
- term.getCursorPos = function()
- local x, y = _getCursorPos()
- return x, y - 1
- end
- -- Make sure we save the current state of the terminal (e.g. colors and cursor pos)
- local function save()
- return {
- colors.black, -- Implement at some point
- colors.white,
- {_getCursorPos()}
- }
- end
- -- Restore state of terminal
- local function restore(ts)
- term.setBackgroundColor(ts[1])
- term.setTextColor(ts[2])
- _setCursorPos(ts[3][1], ts[3][2])
- end
- local w, h = _getSize()
- -- Our function for writing to that first line
- local function writeMobStatus()
- while true do
- local e = {os.pullEvent("modem_message")}
- local ts = save()
- _setCursorPos(1,1)
- term.setBackgroundColor(colors.red)
- term.write(string.rep(" ", w))
- _setCursorPos(1,1)
- term.setTextColor(colors.white)
- term.write("Mobs: " .. e[5])
- restore(ts)
- end
- end
- -- A helper method to run the shell
- local function runTerm()
- shell.run("rom/programs/shell")
- end
- -- Clear the terminal so it's nice and clean that first go
- term.clear()
- -- And bam!
- parallel.waitForAll(writeMobStatus, runTerm)
Advertisement
Add Comment
Please, Sign In to add comment