Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local border={}
- local component = require'component'
- local unicode = require('unicode')
- local gpu = require('component').gpu
- local b = 0x2800 --brail
- --local bits = {1,8,2,16,4,32,64,128}
- local line={
- left=unicode.char(184+b),
- right=unicode.char(71+b),
- top=unicode.char(192+b),
- bottom=unicode.char(9+b),
- lefttop=unicode.char(128+b),
- leftbottom=unicode.char(8+b),
- righttop=unicode.char(64+b),
- rightbottom=unicode.char(1+b)
- }
- function border.box(x,x2,y,y2)
- local topline = line.lefttop
- local bottomline = line.leftbottom
- for _ = x, x2 , 1 do
- topline = topline .. line.top
- bottomline = bottomline .. line.bottom
- end
- topline = topline .. line.righttop
- bottomline = bottomline .. line.rightbottom
- gpu.set(x-1,y-1,topline)
- for f=y,y2,1 do
- gpu.set(x-1,f,line.left)
- gpu.set(x2+1,f,line.right)
- end
- gpu.set(x-1,y2+1,bottomline)
- return true
- end
- --text by custom coords with color attributes
- function border.put(text,x,y,font,field,box)
- if text then
- text=tostring(text)
- else text = 'put your text here'
- end
- x=x or 2
- y=y or 2
- box = box or 0xa000a0
- field = field or 0x00e000
- font = font or 0xf00000
- local foreground = gpu.getForeground()
- local background = gpu.getBackground()
- gpu.setForeground(box)
- border.box(x,x+#text-1,y,y)
- gpu.setForeground(font) gpu.setBackground(field)
- gpu.set(x,y,text)
- gpu.setBackground(background) gpu.setForeground(foreground)
- return true
- end
- local energy={' ','K ','M ','G ','T ','P '}
- --конвертирует число в тир энергии
- function border.energyTier(number,energy_name)
- energy_name = energy_name or 'RF/t'
- local tier=1
- while number>1000 do
- tier=tier+1 number=number/1000
- if tier == #energy then break end
- end
- number = string.sub(number,1,5)
- return(number..energy[tier]..energy_name),tier
- end
- --[[
- local num = tostring(number)
- local tier = tostring(#number//1)//3
- function printNumArrayAsTable(numArray)
- return true
- end
- ]]
- function border.getDevice(name)
- local name=name or 'computer'
- local device={}
- local c=component.list()
- for k,v in pairs(c) do if string.find(v,name) then
- device[#device+1]=component.proxy(k) end
- end
- return device
- end
- return border
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement