Guest User

BTMLobby

a guest
Jul 24th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.51 KB | None | 0 0
  1. local textToASCII = require("textToASCII")
  2. local component = require("component")
  3. local gpu = component.getPrimary("gpu")
  4. local term = require("term")
  5. local rgbHex = require("rgbHex")
  6.  
  7. --Vars
  8. local changeTime = 500 --How fast the screen changes
  9. local labelWidth = 30 --Width of Lables
  10. local panelWidth = 80 --Width of Panel Labels
  11. local panelistWidth = 20 --Width of Panelist Labels
  12. local tableTitleY = 10 --Y Coordinate of Table Title
  13. local tableTitleHeight = 4 --Height of Table Title
  14. local screenX=130 --Screen Size (Don't Change X, can lower Y to aprox 37)
  15. local screenY=40  --Max: 160x50, 16:9 = 160x45, Default (2:1) = 130x40
  16. local label3X = screenX/2-labelWidth/2
  17. local panelX = screenX/2 -(panelWidth+panelistWidth)/2
  18. local panelistX = panelX+panelWidth
  19.  
  20. gpu.setResolution(screenX,screenY)
  21. term.clear()
  22.  
  23. local objectsLobby = {}
  24. local objectsLobby2 = {}
  25. local objectsPanel = {}
  26. function newLabel(ID,label,x,y,width,height,color,page)
  27.     local table = {}
  28.     table["label"] = label
  29.     table["x"] = x
  30.     table["y"] = y
  31.     table["width"] = width
  32.     table["height"] = height
  33.     table["color"] = color
  34.     if page == 1 then
  35.         objectsLobby[ID] = table
  36.     elseif page == 2 then
  37.         objectsLobby2[ID] = table
  38.     else
  39.         objectsPanel[ID] = table
  40.     end
  41. end
  42.  
  43. function draw(ID,page)
  44.     if page == 1 then
  45.         data = objectsLobby[ID]
  46.     elseif page == 2 then
  47.         data = objectsLobby2[ID]
  48.     else
  49.         data = objectsPanel[ID]
  50.     end
  51.     local objtype = data["type"]
  52.     local label = data["label"]
  53.     local x = data["x"]
  54.     local y = data["y"]
  55.     local width = data["width"]
  56.     local height = data["height"]
  57.    
  58.     gpu.setBackground(data["color"],false)
  59.     gpu.fill(x,y,width,height," ")
  60.     gpu.set((x+width/2)-string.len(label)/2,y+height/2,label)
  61.     gpu.setBackground(0x000000,false)
  62. end
  63.  
  64. function drawAll(page)
  65.     gpu.setForeground(0x000000)
  66.     gpu.fill(label3X-2.5*(labelWidth+4),tableTitleY,labelWidth,screenY-tableTitleY," ")
  67.     if page == 1 then
  68.         for ID,data in pairs(objectsLobby) do
  69.             draw(ID,page)
  70.         end
  71.     elseif page ==2 then
  72.         for ID,data in pairs(objectsLobby2) do
  73.             draw(ID,page)
  74.         end
  75.     else
  76.         for ID,data in pairs(objectsPanel) do
  77.             draw(ID,page)
  78.         end
  79.     end
  80. end
  81. --[[
  82. local tapeDrive = {}
  83. local i = 1
  84. for address, type in pairs(component.list("tape")) do
  85.   tapeDrive[i] = address
  86.   i = i+1
  87. end
  88. --]]
  89. local w,h = gpu.getResolution()
  90. --[[
  91. component.invoke(tapeDrive[1],"play")
  92. component.invoke(tapeDrive[1],"setSpeed",0.75)
  93. component.invoke(tapeDrive[2],"setSpeed",0.75)
  94. --]]
  95.  
  96. local rgb = {255,0,0}
  97. local hex = rgbHex.convert(rgb)
  98.  
  99. gpu.setPaletteColor(1,tonumber(hex))
  100. gpu.setForeground(1,true)
  101. local btmTitle = textToASCII.convert("Welcome to BTM 2016 2.0","big",true,true)
  102. local titleLength = #btmTitle[1]
  103. for i, line in ipairs(btmTitle) do
  104.   term.setCursor(w/2-titleLength/2,i)
  105.   term.write(line)
  106. end
  107.  
  108. local col = 2
  109. local increment = true
  110. function incrementRgb(index)
  111.     if increment then
  112.         rgb[index] = rgb[index]+1
  113.         if rgb[index]>=255 then
  114.             if col == 1 then
  115.                 col = 3
  116.             else
  117.                 col = col -1
  118.             end
  119.             increment = false
  120.         end
  121.     else
  122.         rgb[index] = rgb[index]-1
  123.         if rgb[index]<=0 then
  124.             if col == 1 then
  125.                 col = 3
  126.             else
  127.                 col = col -1
  128.             end
  129.             increment = true
  130.         end
  131.     end
  132. end
  133.  
  134. --Format: name, size, continues onto next line
  135. local stalls = {
  136.     [0]={
  137.         {"DJ Flamin' GO",1},
  138.         {"Correlated Foodalistics",1}
  139.     },
  140.     [1]={
  141.         {"IndustrialCraft",1,true},
  142.         {"2",1},
  143.         {"Harvest Festival",1},
  144.         {"ArmorPlus / WeaponsPlus",1},
  145.         {"OpenRadio",1},
  146.         {"Correlated Potentialistics",1},
  147.         {"Rarmor",1},
  148.         {"Actually Additions",1},
  149.         {"Dark Utils",1},
  150.         {"Additional Banners",1},
  151.         {"Quaritum",1},
  152.         {"Engination Enginogrammetry",1},
  153.         {"Taam",2},
  154.         {"RandomThings",1},
  155.         {"AbbysalCraft",1}
  156.     },
  157.     [2]={
  158.         {"Ender Utilities",1},
  159.         {"Forestry",1},
  160.         {"Unclaimed",1},
  161.         {"Integrated Dynamics",1},
  162.         {"Chisel",2},
  163.         {"P&P",2},
  164.         {"Fancy Fluid",1,true},
  165.         {"Storage",1},
  166.         {"",1,true},
  167.         {"Open",1,true},
  168.         {"Computers",1,true},
  169.         {"",1},
  170.         {"TechReborn",1},
  171.         {"Autoverse",1}
  172.     },
  173.     [3]={
  174.         {"Unclaimed",1},
  175.         {"Holographic Victory Monuement",1},
  176.         {"Extra Food",1},
  177.         {"Starvation Ahoy",1},
  178.         {"Automated Redstone",1},
  179.         {"Inductive Automation",1},
  180.         {"Unclaimed",1},
  181.         {"ljfa's Mod",1},
  182.         {"Blay09 and Zero_'s Mods",1},
  183.         {"Unclaimed",3},
  184.         {"DeepResonance",1},
  185.         {"RFTools",1},
  186.         {"ChickenBones' Mods",1},
  187.         {"Draconic Evolution",1}
  188.     },
  189.     [4]={
  190.         {"Unclaimed",16}
  191.     },
  192.     [5]={
  193.         {"Unclaimed",2},
  194.         {"",true},
  195.         {"Glitchfiend's",1,true},
  196.         {"Mods",1,true},
  197.         {"",1},
  198.         {"Unclaimed",1},
  199.         {"Our Lord and Savior Flamingo",1},
  200.         {"Pink Black Hole",1},
  201.         {"Unclaimed",3},
  202.         {"Better With Mods",1},
  203.         {"Unclaimed",1},
  204.         {"FTB Wiki",1},
  205.         {"Unclaimed",1}    
  206.     },
  207.     [6]={
  208.         {"Unclaimed",4},
  209.         {"Ender IO",1},
  210.         {"Unclaimed",9},
  211.         {"The_Fireplace's",1,true},
  212.         {"Mods",1}
  213.     }
  214. }
  215.  
  216. --Format: name, panelist
  217. local panels = {
  218.     {"IC2 Mystery Panel","Aroma1997"},
  219.     {"MCubed - a project to build a Curse alternative", "Gaelan"},
  220.     {"OpenGL for Minecraft Modders", "GreaseMonkey"},
  221.     {"OpenOS 1.6 - What's New?", "payonel"},
  222.     {"TIS-OC", "Sangar"},
  223.     {"Translation in a Nutshell - The Chinese modded Minecraft community","3TUSK and exzhawk"},
  224.     {"Will it run on Minecraft? - MIPS for OpenComputers","GreaseMonkey"},
  225.     {"Beyond Cellular Automation - Designing better machines for multiplayer","Falkreon"},
  226.     {"Please Stop Playing Minecraft - How to make better maps and mods","Moesh"}
  227. }
  228.  
  229. function level()
  230.     --Level 0
  231.     newLabel("Level0Title","Level 0",label3X,tableTitleY+22,labelWidth,tableTitleHeight,0xff9933,1)
  232.     local pos = tableTitleHeight+tableTitleY+22
  233.     for i=1,#stalls[0] do
  234.         if i%2==0 then
  235.             newLabel("L0-Stall"..i,stalls[0][i][1],label3X,pos,labelWidth,stalls[0][i][2],0xffbf80,1)
  236.         else
  237.             newLabel("L0-Stall"..i,stalls[0][i][1],label3X,pos,labelWidth,stalls[0][i][2],0xffd9b3,1)
  238.         end
  239.         pos = pos+ stalls[0][i][2]
  240.     end
  241.    
  242.     --Levels 1-3
  243.     for l=1,3 do
  244.         newLabel("Level"..l.."Title","Level "..l,label3X+(l-2)*(labelWidth+4),tableTitleY,labelWidth,tableTitleHeight,0xff9933,1)
  245.         local pos = tableTitleHeight+tableTitleY
  246.         local rev = false
  247.         for i=1,#stalls[l] do
  248.             if (i%2==0)~=rev then
  249.                 newLabel("L"..l.."-Stall"..i,stalls[l][i][1],label3X+(l-2)*(labelWidth+4),pos,labelWidth,stalls[l][i][2],0xffbf80,1)
  250.             else
  251.                 newLabel("L"..l.."-Stall"..i,stalls[l][i][1],label3X+(l-2)*(labelWidth+4),pos,labelWidth,stalls[l][i][2],0xffd9b3,1)
  252.             end
  253.             if stalls[l][i][3] then
  254.                 rev = not rev
  255.             end
  256.             pos = pos+ stalls[l][i][2]
  257.         end
  258.     end
  259. end
  260.  
  261. function level2()
  262.     --Levels 4-6
  263.     for l=4,6 do
  264.         newLabel("Level"..l.."Title","Level "..l,label3X+(l-5)*(labelWidth+4),tableTitleY,labelWidth,tableTitleHeight,0xff9933,2)
  265.         local pos = tableTitleHeight+tableTitleY
  266.         local rev = false
  267.         for i=1,#stalls[l] do
  268.             if (i%2==0)~=rev then
  269.                 newLabel("L"..l.."-Stall"..i,stalls[l][i][1],label3X+(l-5)*(labelWidth+4),pos,labelWidth,stalls[l][i][2],0xffbf80,2)
  270.             else
  271.                 newLabel("L"..l.."-Stall"..i,stalls[l][i][1],label3X+(l-5)*(labelWidth+4),pos,labelWidth,stalls[l][i][2],0xffd9b3,2)
  272.             end
  273.             if stalls[l][i][3] then
  274.                 rev = not rev
  275.             end
  276.             pos = pos+ stalls[l][i][2]
  277.         end
  278.     end
  279. end
  280.  
  281. function showPanels()
  282.     newLabel("PanelTitle","Panel",panelX,tableTitleY,panelWidth,tableTitleHeight,0xff9933,3)
  283.     newLabel("PanelistTitle","Panelist",panelistX,tableTitleY,panelistWidth,tableTitleHeight,0xff9933,3)
  284.     local pos = tableTitleHeight+tableTitleY
  285.     for i=1,#panels do
  286.         if i%2==0 then
  287.             newLabel("Panel"..i,panels[i][1],panelX,pos,panelWidth,2,0xffbf80,3)
  288.             newLabel("Panelist"..i,panels[i][2],panelistX,pos,panelistWidth,2,0xffbf80,3)
  289.         else
  290.             newLabel("Panel"..i,panels[i][1],panelX,pos,panelWidth,2,0xffd9b3,3)
  291.             newLabel("Panelist"..i,panels[i][2],panelistX,pos,panelistWidth,2,0xffd9b3,3)
  292.         end
  293.         pos = pos+2
  294.     end
  295. end
  296.  
  297. level()
  298. level2()
  299. showPanels()
  300. drawAll(1)
  301. local timer = 0
  302. local page = 1
  303.  
  304. local drive = 1
  305. --Main Loop
  306. while true do
  307.   --[==[Tape Drive Script
  308.     if component.invoke(tapeDrive[drive],"isEnd") then
  309.         component.invoke(tapeDrive[drive],"seek",-component.invoke(tapeDrive[drive],"getSize"))
  310.         if drive == 1 then
  311.             drive = 2
  312.         else
  313.             drive = 1
  314.         end
  315.         component.invoke(tapeDrive[drive],"play")
  316.     end
  317.     --]==]
  318.     if timer == changeTime then
  319.         gpu.setForeground(0x000000)
  320.         gpu.fill(1,tableTitleY,screenX,screenY-tableTitleY," ")
  321.         if page == 3 then
  322.             page = 1
  323.         else
  324.             page = page + 1
  325.         end
  326.         drawAll(page)
  327.         timer = 0
  328.     else
  329.         timer = timer + 1
  330.     end
  331.    
  332.     incrementRgb(col)
  333.     hex = rgbHex.convert(rgb)
  334.     gpu.setPaletteColor(1,tonumber(hex))
  335. end
Add Comment
Please, Sign In to add comment