Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- OOS=require("OOS")
- component=require("component")
- w,h=component.gpu.getResolution()
- running=true
- exit=OOS.makeButton("gpu",{w-3,h},"exit",0x000000,0xff0000,{char="q"})
- tab={
- "tab1";
- "tab2";
- "tab3";
- "tab4";
- "tab5";
- "tab6";
- "tab7";
- "tab8";
- "tab9";
- }
- oddbjorn={}
- for i=1,45 do
- oddbjorn[i]={string=string.rep("X",math.random(0,9)),slot=i};
- end
- tabs=function(tab)
- tabs={}
- for i=1,#tab do
- tabs[i]=OOS.makeButton("gpu",{w-3,2*i},tab[i],0xffffff,0x000000,{char=tostring(i),isToggle=true})
- end
- return tabs
- end
- currentTab=1
- sidebar=tabs(tab)
- drawSidebar=function(e)
- for i=1,#sidebar do
- if sidebar[i]:detect(e) then
- for q=1,#sidebar do
- sidebar[q].hit=false
- end
- sidebar[i].hit=true
- currentTab=i
- end
- end
- for i=1,#sidebar do
- if sidebar[i].hit then
- if not sidebar[i].hit==sidebar[i].lastHit then
- sidebar[i]:changeColor(0xffffff,0xff0000)
- sidebar[i]:vanish()
- sidebar[i]:draw()
- sidebar[i].lastHit=sidebar[i].hit
- end
- else
- if not sidebar[i].hit==sidebar[i].lastHit then
- sidebar[i]:changeColor(0xffffff,0x0000ff)
- sidebar[i]:vanish()
- sidebar[i]:draw()
- sidebar[i].lastHit=sidebar[i].hit
- end
- end
- end
- end
- makeButtons=function(data)
- buttons={}
- foundLeap=false
- leap=0
- maxlenght=0
- for i=1,#data do
- if #data[i].string > maxlenght then maxlenght=#data[i].string end
- end
- maxlenght=maxlenght+3
- xnmb=math.floor(w/(maxlenght+1))-2
- ynmb=math.floor(h/(4))-2
- i=1
- for x=1,xnmb do
- for y=1,ynmb do
- if i>#data then break end
- xPos=x*maxlenght+2
- yPos=y*4+1
- buttons[i]={button=OOS.makeButton("gpu",{xPos,yPos},{"/"..string.rep("-",#data[i].string).."\\","|"..data[i].string.."|","\\"..string.rep("-",#data[i].string).."/"},0xffffff,0x0000ff);slot=data[i].slot}
- i=i+1
- end
- end
- return buttons
- end
- drawButton=function(buttonList)
- for i =1,#buttonList do
- buttonList[i].button:draw()
- end
- end
- detectButton=function(buttonlist,e)
- toreturn=" "
- for i=1,#buttonlist() do
- if buttonList[i].button:detect(e) then
- toreturn=i
- break
- end
- end
- return toreturn
- end
- vanishButton=function(buttonList)
- for i=1,#buttonList do
- buttonList[i].button:vanish()
- end
- end
- for i=1,#tab*2+1 do
- if i==1 then
- component.gpu.set(w-4,i,"/----")
- elseif i==2*#tab+1 then
- component.gpu.set(w-4,i,"\\----")
- elseif i%2==1 then
- component.gpu.set(w-4,i,"+----")
- else
- component.gpu.set(w-4,i,"|")
- end
- end
- oddbjornButtons=makeButtons(oddbjorn)
- drawButton(oddbjornButtons)
- --os.sleep(3)
- --vanishButton(oddbjornButtons)
- for i=1,#sidebar do
- sidebar[i]:draw()
- sidebar[i].lastHit=true
- end
- while running do
- e=OOS.eventHandle(1)
- exit:draw()
- if exit:detect(e) then running=false end
- drawSidebar(e)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement