Advertisement
Guest User

showcase

a guest
Dec 20th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.45 KB | None | 0 0
  1. mon = peripheral.wrap("bottom")
  2. mon.setTextScale(0.5)
  3. os.loadAPI("data") -- Yes. I wrote my own API :D
  4. mon.setBackgroundColor(colors.black)
  5. mon.clear()
  6. mX, mY = mon.getSize()
  7. frameName = "frame"
  8. frameCount = 1
  9. delay = 0.25
  10. wipeBeforeWrite = false
  11. wipeColor = colors.black
  12.  
  13. itemText = {
  14. "Chrome"
  15. }
  16.  
  17. function getPictureWidth(picDef)
  18.  pictureBuff = data.linesTable(picDef)
  19.  oldC = 1
  20.  for i=1,#pictureBuff do
  21.   oldC = math.max(oldC, string.len(pictureBuff[i]))
  22.  end
  23.  return oldC
  24. end
  25.  
  26. function loadFrames()
  27.  frames = {}
  28.  for i=1,frameCount do
  29.   table.insert(frames, paintutils.loadImage(frameName..tostring(i)))
  30.  end
  31. end
  32.  
  33. function drawFrame(frameNumberC,textNR, xPosP, yPosP)
  34.  terminal = term.current()
  35.  term.redirect(mon)
  36.  textStartPos =  (getPictureWidth(frameName..tostring(textNR))/2) - (string.len(itemText[textNR])/2)
  37.  term.setCursorPos(textStartPos+xPosP,1)
  38.  term.setTextColor(colors.white)
  39.  term.setBackgroundColor(colors.black)
  40.  term.write(itemText[textNR])
  41.  paintutils.drawImage(frameNumberC,xPosP,yPosP)
  42.  term.redirect(terminal)
  43. end
  44.  
  45. function main()
  46.  for i=1,frameCount do
  47.   if fs.exists("CloseShop") == false then
  48.    if wipeBeforeWrite == true then
  49.     mon.setBackgroundColor(wipeColor)
  50.     mon.clear()
  51.    end
  52.    drawFrame(frames[i],i, mX/2 ,3)
  53.    sleep(delay)
  54.   else
  55.    fs.delete("CloseShop")
  56.    shell.switchTab(2)
  57.    os.queueEvent("terminate")
  58.   end
  59.  end
  60. end
  61.  
  62. loadFrames()
  63. while true do
  64.  main()
  65.  sleep(delay)
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement