Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tX,tY,cX,cY
- function getVersion()
- ver = "0.1"
- return ver
- end
- -- BASIC FUNCTIONS
- function clear(delay)
- if delay == true then
- os.sleep(1)
- end
- term.clear()
- term.setCursorPos(1,1)
- end
- function newLine(indent)
- if indent == nil then
- indent = 0
- end
- cX,cY = term.getCursorPos()
- term.setCursorPos(1+indent,cY+1)
- end
- function cPrint(text,line)
- if line == nil then
- cX,cY = term.getCursorPos()
- line = cY
- end
- tX,tY = term.getSize()
- term.setCursorPos( (tX/2) - (#text/2), line )
- term.write(text)
- end
- -- END OF BASIC FUNCTIONS
- function drawAlertBox()
- tX,tY = term.getSize()
- temp = (tY/2)-4
- term.setCursorPos(1,temp)
- for i=1,7 do
- if i%7 == 0 or i%7 == 1 then
- cPrint("*******************************") newLine()
- else
- cPrint("* *") newLine()
- end
- end
- end
- function alertBox(info)
- drawAlertBox()
- term.setCursorPos(1,(tY/2)-2)
- cPrint(info)
- term.setCursorPos(1,tY-1)
- end
- -- FILE HANDLES
- function addLinetoFile(text,file)
- temp = {}
- if not fs.exists(file) then
- print("Creating file")
- clear(true)
- f = io.open(file,"w")
- f:close()
- end
- f = io.open(file,"r")
- if f == nil then
- error("Failed to load")
- return nil
- end
- for line in f:lines() do
- temp[#temp+1] = line
- end
- temp[#temp+1] = text
- f:close()
- f = fs.open(file,"w")
- for i=1,#temp do
- f.writeLine(temp[i])
- end
- f:close()
- end
- function delLinefromFile(text,file)
- temp = {}
- f = io.open(file,"r")
- if f == nil then
- error("File not Found")
- return nil
- end
- for line in f:lines() do
- if not(string.lower(line) == string.lower(text)) then
- temp[#temp+1] = line
- end
- end
- f:close()
- f = fs.open(file,"w")
- if f == nil then
- return nil
- end
- for i=1,#temp do
- f.writeLine(temp[i])
- end
- f.close()
- end
Advertisement
Add Comment
Please, Sign In to add comment