Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function register(name, s, t)
- local out = t
- out[name]={}
- if type(t["names"])~="table" then
- t["names"]={}
- end
- if type(t.side) ~= string then
- t.side = s
- end
- table.insert(t["names"], name)
- return out
- end
- function center(min_,max_, text)
- local div_int = (max_ - min_)/2
- local mod_int = div_int%2
- local out_temp = div_int+mod_int
- local len_int = string.len(text)
- if len_int > (max_-min_) then
- local out = out_temp-(len_int/2)
- return out
- elseif string.len(text)<1 then
- return out_temp
- else
- return -1
- end
- end
- peripheral.find = function(returns)
- local _sSides = {
- "front","back",
- "right","left",
- "top", "bottom"
- }
- local _pT = {}
- local _pT.out = {}
- local enable = 1
- local remaining = returns
- for i=1, #_sSides*enable do
- if peripheral.isPresent( _sSides[i] ) then
- local tMethods = peripheral.getMethods( _sSides[i] )
- local tResult = {}
- for n,sMethod in ipairs( tMethods ) do
- tResult[sMethod] = function( ... )
- return peripheral.call( _sSides[i], sMethod, ... )
- end
- end
- if remaining >= 1 then
- _pT.out[sSide[i]].return_s = tResult
- local temp = remaining
- remaining = temp - 1
- end
- if remaining == 0 then
- enabled = 0
- return _pT
- end
- end
- return nil
- end
- function table:create(side, name, ...)
- --takes arguments in order:
- -- side, name, xMin, yMin, xMax, yMax,...
- --... text, bC(background color), tC(text color)
- local vguiOut = register(name, side, vguiIn)
- local vguiOut = nil
- if type(...) == "table" then
- vguiOut = ...
- elseif type(...) ~= "table" then
- vguiOut = {...}
- end
- vguiOut[name]["xMin"]=vguiIn[1]
- local xMin = vguiIn[1]
- vguiOut[name]["yMin"]=vguiIn[2]
- local yMin = vguiIn[2]
- vguiOut[name]["xMax"]=vguiIn[3]
- local xMax = vguiIn[3]
- vguiOut[name]["yMax"]=vguiIn[4]
- local yMax = vguiIn[4]
- local text = vguiIn[5]
- local bC = vguiIn[6]
- local tC = vguiIn[7]
- local center = {}
- center.x = center(xMin, xMax, text)
- center.y = center(yMin, yMax, text)
- local drawText = 0
- if not centerX == -1 and not centerY == -1 then
- drawText = 1
- end
- for x = xMin, xMax do
- for y = yMin, yMax do
- self.out[side].setCursorPos(x,y)
- self.out[side].setBackgroundColor(bC)
- self.out[side].setTextColor(tC)
- if drawText then
- if x==centerX and y == centerY then
- self.out[side].write(text)
- elseif x>xMin+string.len(text) then
- self.out[side].write(" ")
- end
- else
- self.out[side].write(" ")
- end
- end
- end
- return vguiOut
- end
- function checkClk(tbl_)
- local e, b, x, y = os.pullEvent(moniter_touch)
- for i, v in pairs(tbl_) do
- if x >= v["xMin"] and x <= v["xMax"] then
- if y >= v["yMin"] and y < = v["yMax"] then
- return t["names"][i]
- else
- return t["names"][i]
- end
- end
- end
- end
- function table:fill(name,tbl_,bC)
- tbl_[6]=bC
- local _sCall = tbl_.side
- self.out[_sCall]:create(name, tbl_)
- end
Add Comment
Please, Sign In to add comment