Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- in:
- Lua, Computer craft, Coding, and 4 more
- LUA Vertical Scroller
- Edit
- Comments
- 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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement