Advertisement
CaptainSpaceCat

Grapher

May 28th, 2015
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. w, h = term.getSize()
  2. term.setBackgroundColor(colors.blue)
  3. term.clear()
  4. term.setCursorPos(w/2 - 4, 1)
  5. term.write("Grapher")
  6. term.setCursorPos(1, 3)
  7. term.write("y=")
  8. local input = read()
  9. oTemp = fs.open("_runGraph", "w")
  10. oTemp.writeLine("graphtab = {}")
  11. oTemp.writeLine("for x = 1, " .. tostring(w) .. " do")
  12. oTemp.writeLine("  graphtab[x] = " .. tostring(input))
  13. oTemp.writeLine("end")
  14. oTemp.flush()
  15. oTemp.close()
  16. os.loadAPI("_runGraph")
  17. term.setBackgroundColor(colors.black)
  18. term.clear()
  19. for i = 1, #_runGraph.graphtab - 1 do
  20.   paintutils.drawLine(i, h - _runGraph.graphtab[i] + 1, i + 1, h - _runGraph.graphtab[i + 1] + 1, colors.green)
  21.   term.setCursorPos(1, 1)
  22. end
  23. for i, v in pairs(_runGraph.graphtab) do
  24.   paintutils.drawPixel(i, h - v + 1, colors.blue)
  25.   term.setCursorPos(1, 1)
  26. end
  27. shell.run("delete _runGraph")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement