LDShadowLord

Project Colligo

Feb 11th, 2014
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.29 KB | None | 0 0
  1. --[[
  2. This API, Project Colligo, is the sole work of LDShadowLord. If you wish to use this API in your program it MUST be kept as its own file and loaded as an API with os.loadAPI() this header must also be kept intact!
  3. ]]
  4.  
  5. w,h = term.getSize()
  6.  
  7. lvart1 = {"[MSG]","[GUD]","[ERR]","[SVR]","[404]","[501]","[403]","[412]","[204]","[411]"}
  8. lvart2 = {2048,8192,16,2,2,16,16,16,16,16}
  9.  
  10. function getVersion()
  11.   local varstri = "Project Colligo - 0.140A"
  12.   return varstri
  13. end
  14.  
  15. function reset()
  16.   term.setTextColour(colours.white)
  17.   term.setCursorPos(1,1)
  18.   term.clear()
  19. end
  20.  
  21. function isAdvanced()
  22.   return term.isColor and term.isColor()
  23. end
  24.  
  25. function attachPeripheral(type)
  26.   local periphno = 1
  27.   local ldata = peripheral.find(type)
  28.   local doing = true
  29.   local returned = {}
  30.   while doing do
  31.     for i=1, #ldata do
  32.       peripheral.wrap(ldata[i])
  33.       table.insert(returned, ldata[i])
  34.     end
  35.   end
  36.   return returned
  37. end
  38.  
  39. function aPrint(type,text)
  40.   if type == "c" then
  41.     local lvarx,lvary = term.getCursorPos()
  42.     local lvar2 = #text
  43.     local lvar3 = math.floor((w-lvar2)/2)
  44.     term.setCursorPos(lvar3,lvary)
  45.     print(text)
  46.   elseif type == "r" then
  47.     local lvarx, lvary = term.getCursorPos()
  48.     local lvar2 = #text
  49.     term.setCursorPos(w-lvar2-1,lvary)
  50.     print(text)
  51.   elseif type == "l" then
  52.     local lvarx, lvaryy = term.getCursorPos()
  53.     term.setCursorPos(2,lvary)
  54.     print(text)
  55.   end
  56. end
  57.  
  58. function aWrite(type,text)
  59.   if type == "c" then
  60.     local lvarx,lvary = term.getCursorPos()
  61.     local lvar2 = #text
  62.     local lvar3 = math.floor((w-lvar2)/2)
  63.     term.setCursorPos(lvar3,lvary)
  64.     write(text)
  65.   elseif type == "r" then
  66.     local lvarx, lvary = term.getCursorPos()
  67.     local lvar2 = #text
  68.     term.setCursorPos(w-lvar2-1,lvary)
  69.     write(text)
  70.   elseif type == "l" then
  71.     local lvarx, lvaryy = term.getCursorPos()
  72.     term.setCursorPos(2,lvary)
  73.     write(text)
  74.   end
  75. end
  76.  
  77. function erPrint(type,message)
  78.   local lvar = #lvart1 + 1
  79.   local lvar2 = #lvart2 + 1
  80.   if lvar ~= lvar2 then
  81.     error("Tables do not match")
  82.   else
  83.     if isAdvanced() == true then
  84.       if type <lvar then
  85.         term.setTextColour(lvart2[type])
  86.         write(lvart1[type].." ")
  87.         term.setTextColour(1)
  88.         print(message)
  89.       elseif type == 36956 then
  90.         term.setTextColour(16384)
  91.         write("[FTL] ")
  92.         term.setTextColour(16384)
  93.         print(message)
  94.       end
  95.     end
  96.   end
  97.   term.setTextColour(1)
  98. end
  99.  
  100.  
  101. --[[
  102. function guibutt(name,x,xx,y,colour,text)
  103.   local lvar1 = xx-x
  104.   local doing = true
  105.   if lvar1 < #text then
  106.     error("Text is larger than container!")
  107.   else
  108.     while doing do
  109.       local event,button, cx, cy = os.pullEvent("mouse_click")
  110.       if cx>x and cx<xx and cy == y then
  111.         return true
  112.         break
  113.       end
  114.     end
  115.   end
  116. end
  117. ]]
  118.  
  119. function getTime()
  120.     timeResult = pcall (function() return (http.get("http://www.timeapi.org/utc/0+hours+after+now?format="..textutils.urlEncode("%d-%m-%y %H:%M"))).readAll() end)
  121.     return timeResult
  122. end
  123.  
  124. --[[
  125. function blog(data)
  126. name = getTime()
  127. doing = true
  128.   while doing do
  129.     if not fs.exists("/logs/") then
  130.       mkdir("/logs")
  131.     else
  132.       if fs.exists("/logs/log-"*) then
  133.     fs.open("name".."[1]",w)
  134.       end
  135.     end
  136.   end
  137. end
  138. ]]
Advertisement
Add Comment
Please, Sign In to add comment