FANDOM



Simple Vertical Scroller Computer Craft This is a very simple vertical Scroller in LUA. 

It runs an infinate loop that can be stopped by pressing [END] key on your keyboard. It will read the text to be displayed from a file called text.txt in the same folder. Complete CODE

tSides = {"left","right","bottom","top","front","back"}

for i = 1, #tSides do
  monitor = peripheral.wrap(tSides[i])
  if monitor then
        side = tSides[i]
        break
  end
end

term.redirect(peripheral.wrap(side))
term.clear()
term.setCursorPos(1,1)
local data = {}
local breakOut = false
logo = [[
                                             
  ____  ____   ____ _____    _    _    _ _   
 |  _ \|  _ \ / ___|_   _|__| | _| | _(_) |_ 
 | |_) | |_) | |  _  | |/ _ \ |/ / |/ / | __|
 |  _ <|  __/| |_| | | |  __/   <|   <| | |_ 
 |_| \_\_|    \____| |_|\___|_|\_\_|\_\_|\__|
                                             
]]

function clearscreen()
    local _,row=term.getCursorPos()
    local _,height=term.getSize()
    width, height = term.getSize()
    term.setCursorPos(1,1)
    dl = ""
    sl = ""
    for g=1,width do
        dl =dl.."_"
        sl = sl.." "
    end
    for y=1,height do
        term.setCursorPos(1,y)
        print(dl)
        sleep(0.01)
    end
    
    for y=1,height do
        term.setCursorPos(1,y)
        print(sl)
        sleep(0.01)
    end
    term.clear()
end

function printTo()
    local _,row=term.getCursorPos()
    local _,height=term.getSize()
    term.setCursorPos(1,1)
    print(logo)
    term.setCursorPos(1,8)
    row = 8
    for i=1,#data do
        print(data[i])
        sleep(1)
        row=row+1
        if row>height then
            row=height
            term.scroll(1)
        end
  end
end

local function readLines(sPath)
    local file = fs.open(sPath, "r")
    local line = file.readLine()
    local lineNum = 0
    
    while line do
        table.insert(data, line)        
        line = file.readLine()
        lineNum = lineNum + 1        
    end
    file.close()
    sleep(1)
end

function newLine()
  local _,cY= term.getCursorPos()
  term.setCursorPos(1,cY+1)
end

function program()
  while true do
    clearscreen()
    printTo()
    sleep(0.5)
  end
end

function exitProgram()
    repeat
        local ev, key = os.pullEvent('key')
    until key == 207
end
readLines("text.txt")
parallel.waitForAny(program, exitProgram)
term.restore()

  Thats it, I usually put it in a file called startup in the world/computer/<number>/ folder so it starts when the server does. Enjoy! - Boduzapho

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.