Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --(C) Corona 2013
- --DO NOT STEAL THIS CODE!!!
- function drawButton(button,side)
- xStart=button["x1"]
- xEnd=button["x2"]
- yStart=button["y1"]
- yEnd=button["y2"]
- fillColor=button["color"]
- x=xEnd-xStart
- y=yEnd-yStart
- textCentery=(yStart+y/2)
- textCenterx=(xStart+(x/2))-(string.len(button["text"])/2)
- monitor=peripheral.wrap(side)
- monitor.setCursorPos(xStart,yStart)
- if button["color"] ~= nil and term.isColor() then
- monitor.setBackgroundColor(button["color"])
- else
- monitor.setBackgroundColor(colors.white)
- end
- for j=1,y do
- for i=1,x do
- monitor.write(" ")
- end
- monitor.setCursorPos(xStart,yStart+j)
- end
- if button["text"] ~= nil and monitor.isColor() then
- monitor.setCursorPos(textCenterx,textCentery)
- monitor.write(button["text"])
- end
- monitor.setBackgroundColor(colors.black)
- end
- function drawBox(area,side)
- m = peripheral.wrap(side)
- x1 = area["x1"]
- x2 = area["x2"]
- y1 = area["y1"]
- y2 = area["y2"]
- color = area["color"]
- xSpan = x2-x1
- ySpan = y2-y1
- cornerCount = 1
- m.setCursorPos(x1,y1)
- for j=1,ySpan do
- for i=1,xSpan do
- if (cornerCount == 1) or (cornerCount == ySpan) or (i == 1) or (i == xSpan) then
- m.setBackgroundColor(color)
- m.write(" ")
- else
- local tx,ty = m.getCursorPos()
- m.setCursorPos(tx+1,ty)
- end
- end
- cornerCount = cornerCount+1
- m.setCursorPos(x1,y1+j)
- end
- end
- function pressed(object,x,y)
- if (object["x1"]<=x) and (object["x2"]>=x) and (object["y1"]<=y) and (object["y2"]>=y) then
- return true
- else
- return false
- end
- end
- function changeColor(button,color)
- button["color"] = color
- draw(button)
- return button
- end
- function cls(side)
- local monitor=peripheral.wrap(side)
- monitor.setBackgroundColor(colors.black)
- monitor.clear()
- end
- function getFocus(area)
- term.setCursorPos(area["x1"]+1,area["y1"]+1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement