Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local w,h = term.getSize()
- term.setTextColor(colors.yellow)
- term.clear()
- term.setCursorPos(1,1)
- print("CraftOS 1.6")
- term.write("> ")
- local on = nil
- local x,y = nil, nil
- local curPos = nil
- local str = ""
- function inscribe(string,a,b,textcol,backcol)
- if a and b then
- term.setCursorPos(a,b)
- end
- if textcol then
- term.setTextColor(textcol)
- end
- if backcol then
- term.setBackgroundColor(backcol)
- end
- write(string)
- end
- function blink(x,y)
- x,y = nil,nil
- if not on then
- x,y = term.getCursorPos()
- inscribe("_",x-1,y,colors.white)
- write(string.rep(" ",w-x))
- term.setCursorPos(x,y)
- on = true
- elseif on then
- x,y = term.getCursorPos()
- inscribe(" ",x-1,y,colors.white)
- write(string.rep(" ",w-x))
- term.setCursorPos(x,y)
- on = nil
- end
- os.startTimer(.4)
- end
- function scribe(string,textcol,backcol)
- x,y = term.getCursorPos()
- inscribe(string,x-1,y,textcol,backcol)
- term.setCursorPos(x+1,y)
- end
- function delete()
- x,y = term.getCursorPos()
- inscribe(" ",x-2,y)
- term.setCursorPos(x-1,y)
- end
- os.startTimer(.4)
- while true do
- local e = {os.pullEventRaw()}
- if e[1] == "timer" and e[2] then
- blink()
- end
- if e[1] == "terminate" then
- inscribe("Terminated \n",_,_,colors.red)
- inscribe("Goodbye \n",_,_,colors.yellow)
- blink()
- sleep(1)
- term.clear()
- os.shutdown()
- end
- if e[1] == "char" then
- scribe(e[2])
- if e[2] then
- str = str..tostring(e[2])
- end
- end
- curPosX,curPosY = term.getCursorPos()
- if (e[1] == "key" and e[2] == 14) and (curPosX > 4 or curPosY < 2) then
- delete()
- str = table.concat{str:sub(1,str:len()-1),"",str:sub(str:len()+1)}
- end
- if e[1] == "key" and e[2] == 28 then
- x,y = term.getCursorPos()
- inscribe(" ",x-1,y)
- print(nil)
- shell.run(str)
- term.setTextColor(colors.yellow)
- write("> ")
- term.setTextColor(colors.white)
- str = ""
- end
- if e[1] == "key" and e[2] == 56 then
- shell.run("pastebin run XAktVaSD")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement