Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getColors()
- for i,v in pairs(colors) do
- if tonumber(v) then
- loadstring(i.."="..v)()
- end
- end
- grey = gray
- lightGrey = lightGray
- end
- function draw(words,x,y,txtcol,backcol)
- --put at top of file/program: local c,r,l = 'c','r','l'; local deftxt,defback
- local w,h = term.getSize()
- local offset = 0
- local writeLn
- words = tostring(words)
- deftxt = deftxt or colors.white
- defback = defback or colors.black
- words = words or " "
- if not (x and y) then
- x,y = term.getCursorPos()
- writeLn = true
- elseif not x then
- x,_ = term.getCursorPos()
- writeLn = true
- elseif not y then
- _,y = term.getCursorPos()
- writeLn = true
- end
- txtcol = txtcol or deftxt
- backcol = backcol or defback
- if not tonumber(x) then
- x = x:gsub(" ", "")
- if x:sub(1, 1) == "l" then
- if x:find("+") then
- offset = tonumber(x:sub(x:find("+") + 1))
- term.setCursorPos(1 + offset, y)
- else
- term.setCursorPos(1, y)
- end
- elseif x:sub(1, 1) == "c" then
- if x:find("+") then
- offset = tonumber(x:sub(x:find("+") + 1))
- term.setCursorPos(w/2 - #words/2 + 1 + offset, y)
- elseif x:find("-") then
- offset = tonumber(x:sub(x:find("-") + 1))
- term.setCursorPos(w/2 - #words/2 + 1 - offset, y)
- else
- term.setCursorPos(w/2 - #words/2 + 1, y)
- end
- elseif x:sub(1, 1) == "r" then
- if x:find("-") then
- offset = tonumber(x:sub(x:find("-") + 1))
- term.setCursorPos(w - #words+ 1 - offset, y)
- else
- term.setCursorPos(w - #words+ 1, y)
- end
- end
- else
- term.setCursorPos(x, y)
- end
- term.setTextColor(txtcol)
- term.setBackgroundColor(backcol)
- if writeLn then
- write(words..'\n')
- else
- write(words)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement