Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- w,h = term.getSize()
- col = { ["white"]=1, ["orange"]=2, ["magenta"]=4, ["lightblue"]=8, ["yellow"]=16, ["lime"]=32, ["pink"]=64, ["gray"]=128, ["lightgray"]=256, ["cyan"]=512, ["purple"]=1024, ["blue"]=2048, ["brown"]=4096, ["green"]=8192, ["red"]=16384, ["black"]=32768 }
- function swrite( str, x, y, color )
- term.setCursorPos(x,y)
- term.setTextColor(col[color])
- term.write(str)
- end
- function swritecenter( str, y, color )
- term.setCursorPos((w/2-#str/2)+1,y)
- term.setTextColor(col[color])
- term.write(str)
- end
- function drawbox( str, x1, x2, y1, y2, strcol, color )
- term.setCursorPos(x1,y1)
- term.setBackgroundColor(col[color])
- term.setTextColor(col[strcol])
- local bw = x2-x1
- local bh = y2-y1
- local bstr = " "
- while #bstr < bw do
- bstr = bstr.." "
- end
- for i=1,bh do
- term.setCursorPos(x1,y1+i-1)
- term.write(bstr)
- end
- term.setCursorPos(x1+bw/2-#str/2,y1+bh/2)
- term.write(str)
- term.setBackgroundColor(col["black"])
- return { [1]=x1, [2]=x2, [3]=y1, [4]=y2 }
- end
- function press( but, event )
- local e,pr1,pr2,pr3 = os.pullEvent()
- if e == event then
- if pr2 >= but[1] and pr2 < but[2] and pr3 >= but[3] and pr3 < but[4] then
- return true
- else
- return false
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment