mibac138

MibCore

Jan 21st, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.53 KB | None | 0 0
  1. tGetPos =  term.getCursorPos
  2. tB = term.setBackgroundColor
  3. tT = term.setTextColor
  4. clear = term.clear
  5. tSize = term.getSize
  6. run = shell.run
  7. RunningProgram = shell.getRunningProgram
  8.  
  9. function tPos(x,y)
  10.  local x = x or 1
  11.  local y = y or 1
  12.  term.setCursorPos(x,y)
  13. end
  14.  
  15. function clearL(pos)
  16.  local pos = pos or tGetPos()
  17.  tPos(1,pos)
  18.  term.clearLine()
  19. end
  20. function wall( char, line, color)
  21.  if color ~= nil then tT(color) end
  22.  local line = line or 1
  23.  tPos(1,line)
  24.  print(char)
  25.  tPos(51,line)
  26.  print(char)
  27. end
  28.  
  29. function pixWall(line, color)
  30.  local line = line or 1
  31.  color = color or white
  32.  paintutils.drawPixel(1,line, color)
  33.  paintutils.drawPixel(51,line, color)
  34. end
  35.  
  36. function Ln(x)
  37.  local x = x or 1
  38.  for i=1,x, 1 do
  39.  print()
  40.  end
  41. end
  42.  
  43. function printLine( text, color)
  44.  if color ~= nil then tT(color) end
  45.  print()
  46.  print(text)
  47. end
  48.  
  49. function printLn( text, color)
  50.  if color ~= nil then tT(color) end
  51.  print()
  52.  print( text )
  53. end
  54.  
  55. function printC( text, color )
  56.  tT(color)
  57.  print( text )
  58. end
  59.  
  60. function writeC( text, color )
  61.  tT(color)
  62.  write( text )
  63. end
  64.  
  65. function getInput( x, y, char)
  66.  local char = char or nil
  67.  tPos(x,y)
  68.  return read(char)
  69. end
  70.  
  71. function TextLine( line , color)
  72.  if color ~= nil then tT(color) end
  73.  tPos(1,line)
  74.  print("+-------------------------------------------------+")
  75. end
  76.  
  77. function drawImage( img, y, x)
  78.  if not fs.exists(img) then error("File " ..img.. " does not exist.") end
  79.  local x = x or 1
  80.  local y = y or 1
  81.  local img = paintutils.loadImage(img)
  82.  paintutils.drawImage(img, y, x)
  83. end
  84.  
  85. function printCentered( text, line, color)
  86.  if color ~= nil then tT(color) end
  87.  local w, h = term.getSize()
  88.  local x = math.floor((w - string.len( text )) / 2)
  89.  tPos(x,line)
  90.  print(text)
  91. end
  92.  
  93. function require(file)
  94.  if not fs.exists(file) then printC("Required file not exists!", red) end
  95. end
  96.  
  97. function wFile(path, text)
  98.  local file = assert(io.open(path, "w"))
  99.  file:write(text)
  100.  file:close()
  101. end
  102.  
  103. function download(adress, save)
  104.  http.get(adress)
  105.  local desc = http.get(adress)
  106.  local file = fs.open(save, "w")
  107.  file.write(desc.readAll())
  108.  file.close()
  109. end
  110.  
  111. function getDir()
  112.  local getDir = shell.dir()
  113.  if getDir == "" then return "/"
  114.  elseif getDir ~= "" then return getDir end
  115. end
  116.  
  117. function cdPath(dir)
  118.  if dir == nil then
  119.   return getDir()
  120.  elseif dir ~= nil then
  121.   shell.run("cd ", dir)
  122.  end
  123. end
  124.  
  125. function createDir(name)
  126.  if name ~= nil then
  127.   shell.run("mkdir ", name)
  128.  elseif name == nil then
  129.   error("createDir: name expected")
  130.  end
  131. end
Advertisement
Add Comment
Please, Sign In to add comment