Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wrapMon()
- for i, v in ipairs(peripheral.getNames()) do
- if peripheral.getType(v) == 'monitor' then
- monitor = peripheral.wrap(v)
- return monitor
- end
- end
- end
- wrapMon()
- function middle()
- width, height = monitor.getSize()
- x = math.floor(width/2)
- y = math.floor(height/2)
- return x, y
- end
- function draw(color)
- monitor.setBackgroundColor(color)
- monitor.write(' ')
- monitor.setBackgroundColor(colors.black)
- end
- function drawDot(x, y, color)
- monitor.setCursorPos(x, y)
- draw(color)
- end
- function drawLine(x1, y1, x2, y2, color)
- x = x2 - x1
- y = y2 - y1
- if x < 0 then
- xinc = -1
- else
- xinc = 1
- end
- if y < 0 then
- yinc = -1
- else
- yinc = 1
- end -- if x1 > x2,
- if math.abs(y/x)>1 then --if the gradient is more than 1
- for i = y1, y2, yinc do
- drawDot(math.floor((x1 + (x/y)*(i-y1)+0.5)), i, color)
- end
- elseif math.abs(y/x)<1 then --if the gradient is less than 1
- for i = x1, x2, xinc do --go along
- drawDot(i, math.floor((y1+(y/x)*(i-x1))+0.5), color)
- end
- else
- for i = x1, x2, xinc do
- drawDot(i, y1+(i-x1), color)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment