Advertisement
LegoStax

Lithium OS Compatibility API

Sep 30th, 2013
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.87 KB | None | 0 0
  1. --[[
  2.     Lithium OS Compatibility API by LegoStax
  3. ]]--
  4. function registerIcon( name, programdir, newx, newy )
  5.     if fs.exists(".programs/icons/iconlist") then
  6.         local file = fs.open(".programs/icons/iconlist", "r")
  7.         icons = textutils.unserialize(file.readAll())
  8.         file.close()
  9.     else
  10.         icons = {}
  11.     end
  12.     icon = {
  13.         txt = name,
  14.         dir = programdir,
  15.         x = tonumber(newx),
  16.         y = tonumber(newy)
  17.     }
  18.     icons[#icons + 1] = icon
  19.     local file = fs.open(".programs/icons/iconlist", "w")
  20.     file.write(texutils.serialize(icons))
  21.     file.close()
  22.     return true
  23. end
  24.  
  25. function getIconList()
  26.     icons = {}
  27.     if fs.exists(".programs/icons/iconlist") then
  28.         local file = fs.open(".programs/icons/iconlist", "r")
  29.         icons = textutils.unserialize(file.readAll())
  30.         file.close()
  31.     end
  32.     return icons
  33. end
  34.  
  35. function drawIcon( icondirect, x, y )
  36.     term.setCursorPos( x, y )
  37.     img = paintutils.loadImage( ".programs/icons/"..icondirect )
  38.     paintutils.drawImage( img, x, y )
  39. end
  40.  
  41. function returnToLith()
  42.     if fs.exists("lithos") then shell.run("lithos")
  43.     else return end
  44. end
  45.  
  46. function alert( title, alerttext, x, y )
  47.     term.setTextColor(colors.white)
  48.     term.setBackgroundColor(colors.blue)
  49.     spaces = #alerttext - #title
  50.     term.setCursorPos(x,y)
  51.     term.write(" "..title)
  52.     start = #title + 2
  53.     for i = start,spaces do
  54.         term.setCursorPos(i,y)
  55.         term.write(" ")
  56.     end
  57.     term.setBackgroundColor(colors.red)
  58.     x2 = #title + 3
  59.     term.setCursorPos(x2,y)
  60.     term.write("X")
  61.     term.setTextColor(colors.lightGray)
  62.     term.setBackgroundColor(colors.lightGray)
  63.     term.setCursorPos(x,y+1)
  64.     term.write(" "..alerttext.."  ")
  65.     term.setTextColor(colors.black)
  66.     term.setCursorPos(x,y+2)
  67.     term.write(" "..alerttext.."  ")
  68.     term.setTextColor(colors.lightGray)
  69.     term.setCursorPos(x,y+3)
  70.     term.write(" "..alerttext.."  ")
  71.     term.setBackgroundColor(colors.black)
  72.     term.setTextColor(colors.white)
  73.     print(spaces)
  74.     print(start)
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement