Advertisement
Nothy

Edge

Jun 18th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. local edge = {}
  2. version = "2.1B"
  3. defc = colors.white
  4. function log(string)
  5. local time = os.clock()
  6. if not fs.exists("Axiom/log.txt") then
  7. logfile = fs.open("Axiom/log.txt","w")
  8. logfile.close()
  9. end
  10. logfile = fs.open("Axiom/log.txt","a")
  11. logfile.writeLine("["..time.."]: "..string.."\n")
  12. logfile.close()
  13. end
  14. function cprint( text, y )
  15. local x = term.getSize()
  16. local centerXPos = ( x - string.len(text) ) / 2
  17. term.setCursorPos( centerXPos, y )
  18. write( text )
  19. end
  20. function c()
  21. local returnTime = textutils.formatTime(os.time(),false)
  22. return returnTime
  23. end
  24. function ico(x,y,imgPath,defaultcolor)
  25. log("[edge] drew icon @ "..x.." "..y..": img: "..imgPath)
  26. if fs.exists("Axiom/images/"..imgPath) then
  27. local img = paintutils.loadImage("Axiom/images/"..imgPath)
  28. if img == nil then
  29. error("nil image data")
  30. end
  31. paintutils.drawImage(img, x, y)
  32. term.setBackgroundColor(defaultcolor)
  33. else
  34. error("[EDGE] No such image: "..imgPath)
  35. end
  36. end
  37. function image(x,y,imgPath,defaultcolor)
  38. log("[edge] Drew image @ "..x.." "..y..": img: "..imgPath)
  39. if fs.exists("Axiom/images/"..imgPath) then
  40. local img = paintutils.loadImage("Axiom/images/"..imgPath)
  41. if img == nil then
  42. error("nil image data")
  43. end
  44. paintutils.drawImage(img, x, y)
  45. term.setBackgroundColor(defaultcolor)
  46. else
  47. error("[EDGE] No such image: "..imgPath)
  48. end
  49. end
  50. function aprint(string , color)
  51. if not term.isColor() then
  52. term.setTextColor(colors.white)
  53. else
  54. term.setTextColor(color)
  55. end
  56. print(string)
  57. term.setTextColor(colors.white)
  58. end
  59. function setbgColor(color)
  60. term.setBackgroundColor(color)
  61. end
  62. function textColor(color)
  63. term.setTextColor(color)
  64. end
  65. function render(x,y,sx,sy,color,defaultcolor,t,tc,shadow)
  66. if string.find(t,c()) or t == "" then
  67.  
  68. else
  69. if fs.getFreeSpace("/") >= 500 then
  70. log("[edge] rendered @ "..x.." "..y.." "..sx.." "..sy..": shaded: "..tostring(shadow).." text: "..t)
  71. end
  72. end
  73. if shadow == true then
  74. paintutils.drawFilledBox(x + 1,y + 1,sx + 1,sy + 1,colors.gray)
  75. end
  76. paintutils.drawFilledBox(x,y,sx,sy,color)
  77. xprint(t,x,y,tc)
  78. setbgColor(defaultcolor)
  79. defc = defaultcolor
  80. end
  81. function box(x,y,sx,sy,color,defcolor,shadow)
  82. if fs.getFreeSpace("/") >= 500 then
  83. log("[edge] rendered @ "..x.." "..y.." "..sx.." "..sy..": shaded: "..tostring(shadow))
  84. end
  85. if shadow == true then
  86. paintutils.drawFilledBox(x + 1,y + 1,sx + 1,sy + 1,colors.gray)
  87. end
  88. paintutils.drawFilledBox(x,y,sx,sy,color)
  89. setbgColor(defaultcolor)
  90. defc = defcolor
  91. end
  92. function xprint(str,x,y,color)
  93. term.setCursorPos(x,y)
  94. aprint(str,color)
  95. term.setCursorPos(1,1)
  96. end
  97. function center(optionalText)
  98. if optionalText then
  99. local w, h = term.getSize()
  100. centerPoint = w / 2 - (string.len(optionalText) / 2)
  101. return centerPoint, h / 2
  102. else
  103. local w, h = term.getSize()
  104. return w / 2, h / 2
  105. end
  106. end
  107. log("Axiom/libraries/edge: Ready;")
  108. log("Axiom/libraries/edge: Version "..version)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement