Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local edge = {}
- version = "2.1B"
- defc = colors.white
- function log(string)
- local time = os.clock()
- if not fs.exists("Axiom/log.txt") then
- logfile = fs.open("Axiom/log.txt","w")
- logfile.close()
- end
- logfile = fs.open("Axiom/log.txt","a")
- logfile.writeLine("["..time.."]: "..string.."\n")
- logfile.close()
- end
- function cprint( text, y )
- local x = term.getSize()
- local centerXPos = ( x - string.len(text) ) / 2
- term.setCursorPos( centerXPos, y )
- write( text )
- end
- function c()
- local returnTime = textutils.formatTime(os.time(),false)
- return returnTime
- end
- function ico(x,y,imgPath,defaultcolor)
- log("[edge] drew icon @ "..x.." "..y..": img: "..imgPath)
- if fs.exists("Axiom/images/"..imgPath) then
- local img = paintutils.loadImage("Axiom/images/"..imgPath)
- if img == nil then
- error("nil image data")
- end
- paintutils.drawImage(img, x, y)
- term.setBackgroundColor(defaultcolor)
- else
- error("[EDGE] No such image: "..imgPath)
- end
- end
- function image(x,y,imgPath,defaultcolor)
- log("[edge] Drew image @ "..x.." "..y..": img: "..imgPath)
- if fs.exists("Axiom/images/"..imgPath) then
- local img = paintutils.loadImage("Axiom/images/"..imgPath)
- if img == nil then
- error("nil image data")
- end
- paintutils.drawImage(img, x, y)
- term.setBackgroundColor(defaultcolor)
- else
- error("[EDGE] No such image: "..imgPath)
- end
- end
- function aprint(string , color)
- if not term.isColor() then
- term.setTextColor(colors.white)
- else
- term.setTextColor(color)
- end
- print(string)
- term.setTextColor(colors.white)
- end
- function setbgColor(color)
- term.setBackgroundColor(color)
- end
- function textColor(color)
- term.setTextColor(color)
- end
- function render(x,y,sx,sy,color,defaultcolor,t,tc,shadow)
- if string.find(t,c()) or t == "" then
- else
- if fs.getFreeSpace("/") >= 500 then
- log("[edge] rendered @ "..x.." "..y.." "..sx.." "..sy..": shaded: "..tostring(shadow).." text: "..t)
- end
- end
- if shadow == true then
- paintutils.drawFilledBox(x + 1,y + 1,sx + 1,sy + 1,colors.gray)
- end
- paintutils.drawFilledBox(x,y,sx,sy,color)
- xprint(t,x,y,tc)
- setbgColor(defaultcolor)
- defc = defaultcolor
- end
- function box(x,y,sx,sy,color,defcolor,shadow)
- if fs.getFreeSpace("/") >= 500 then
- log("[edge] rendered @ "..x.." "..y.." "..sx.." "..sy..": shaded: "..tostring(shadow))
- end
- if shadow == true then
- paintutils.drawFilledBox(x + 1,y + 1,sx + 1,sy + 1,colors.gray)
- end
- paintutils.drawFilledBox(x,y,sx,sy,color)
- setbgColor(defaultcolor)
- defc = defcolor
- end
- function xprint(str,x,y,color)
- term.setCursorPos(x,y)
- aprint(str,color)
- term.setCursorPos(1,1)
- end
- function center(optionalText)
- if optionalText then
- local w, h = term.getSize()
- centerPoint = w / 2 - (string.len(optionalText) / 2)
- return centerPoint, h / 2
- else
- local w, h = term.getSize()
- return w / 2, h / 2
- end
- end
- log("Axiom/libraries/edge: Ready;")
- log("Axiom/libraries/edge: Version "..version)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement