Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local file = fs.open("Rules.txt","r")
- function round(num, dec)
- if dec == nil then dec = 0 end
- local times = math.pow(10,dec)
- num = math.floor(num*times+0.5)
- return num/times
- end
- function string:split(sep)
- local sep, fields = sep or ":", {}
- local pattern = string.format("([^%s]+)", sep)
- self:gsub(pattern, function(c) fields[#fields+1] = c end)
- return fields
- end
- function writeM(mon,txt,x,y,tC,bC)
- if tC == nil then tC = colors.white end
- if bC == nil then bC = colors.black end
- mon.setBackgroundColor(bC)
- mon.setTextColor(tC)
- mon.setCursorPos(x,y)
- mon.write(txt)
- end
- function clearM(mon, color)
- mon.setBackgroundColor(color)
- mon.clear()
- end
- function drawLineM(mon, x1, y1, x2, y2, color)
- local dY = y2-y1
- local dX = x2-x1
- local a = dY/dX
- local b = y1-a*x1
- local pxl = math.sqrt(dY*dY+dX*dX)
- for i = 1, pxl+1 do
- local x = round(dX/pxl*i)
- local y = round(a*x+b)
- local e = "\t|\t"
- if i%5 == 0 then e = "\n" end
- write(x.."\t"..y..e)
- mon.setCursorPos(x,y)
- mon.setBackgroundColor(color)
- mon.write(" ")
- end
- end
- local rules = file.readAll():split("\n")
- file.close()
- print(rules)
- local monitor = peripheral.wrap("top")
- local mW,mH = monitor.getSize()
- print(monitor, mW, mH)
- clearM(monitor,colors.red)
- drawLineM(monitor,1,1,mW,mH,colors.blue)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement