Guest User

Checbox

a guest
Feb 18th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.22 KB | None | 0 0
  1. --dofile("LuaScripts/CreateElement.lua")
  2. top_stack = 1
  3. enabled_scripts = {"bmbgs.lua"}
  4.  
  5. function scroll_up()
  6.     top_stack = (top_stack + 1)
  7.     refresh(0)
  8. end
  9.  
  10. function scroll_down()
  11.     if top_stack ~= 1 then
  12.         top_stack = (top_stack - 1)
  13.         refresh(0)
  14.     end
  15. end
  16.  
  17. function window()  
  18.     win = Window:new(236, 60, 150, 225)
  19.     --close button
  20.     cBtn = Button:new(135, 0, 15, 15, "X")
  21.     cBtn:action(function()interface.closeWindow(win)end)
  22.     win:addComponent(cBtn)
  23.     --reload button
  24.     rBtn = Button:new(80, 0, 50, 15, "RELOAD")
  25.     rBtn:action(refresh(1))
  26.     win:addComponent(rBtn)
  27.     --scroll up button
  28.     uBtn = Button:new(0, 0, 15, 15, "^")
  29.     uBtn:action(scroll_up)
  30.     win:addComponent(uBtn)
  31.     --scroll down button
  32.     dBtn = Button:new(0, 120, 15, 15, "v")
  33.     dBtn:action(scroll_down)
  34.     win:addComponent(dBtn)
  35.    
  36.    
  37.     --stack1
  38.     cb1 = Checkbox:new(0,15, 15, 15) --------------------------------Here the checkbox is defined
  39.     win:addComponent(cb1)
  40.     --stack2
  41.     cb2 = Checkbox:new(0,30, 15, 15)
  42.     win:addComponent(cb2)
  43.     --stack3
  44.     cb3 = Checkbox:new(0,45, 15, 15)
  45.     win:addComponent(cb3)
  46.     --stack4
  47.     cb4 = Checkbox:new(0,60, 15, 15)
  48.     win:addComponent(cb4)
  49.     --stack5
  50.     cb5 = Checkbox:new(0,75, 15, 15)
  51.     win:addComponent(cb5)
  52.     --stack6
  53.     cb6 = Checkbox:new(0,90, 15, 15)
  54.     win:addComponent(cb6)
  55.     --stack7
  56.     cb7 = Checkbox:new(0,105, 15, 15)
  57.     win:addComponent(cb7)
  58.    
  59.     interface.showWindow(win)
  60.     refresh(0)
  61. end
  62.  
  63. function refresh(choice)
  64.     if choice == 1 then
  65.         top_stack = 1
  66.         choice = 0
  67.     end
  68.     cb1:text(" ") -----------------------------------------But here im getting an error.
  69.     cb2:text(" ")
  70.     cb3:text(" ")
  71.     cb4:text(" ")
  72.     cb5:text(" ")
  73.     cb6:text(" ")
  74.     cb7:text(" ")
  75.     local files = fs.list("LuaScripts")
  76.     for k,v in pairs(files) do
  77.         if k <= (top_stack + 6) and k >= top_stack then
  78.             if k == top_stack then --1
  79.                 cb1:text(v)
  80.                 for k2, v2 in pairs(enabled_scripts) do
  81.                     if k == k2 then
  82.                         cb1:checked(true)
  83.                     else
  84.                         cb1:checked(false)
  85.                     end
  86.                 end
  87.             elseif k == (top_stack + 1) then --2
  88.                 cb2:text(v)
  89.                 for k2, v2 in pairs(enabled_scripts) do
  90.                     if k == k2 then
  91.                         cb2:checked(true)
  92.                     else
  93.                         cb2:checked(false)
  94.                     end
  95.                 end
  96.             elseif k == (top_stack + 2) then --3
  97.                 cb3:text(v)
  98.                 for k2, v2 in pairs(enabled_scripts) do
  99.                     if k == k2 then
  100.                         cb3:checked(true)
  101.                     else
  102.                         cb3:checked(false)
  103.                     end
  104.                 end
  105.             elseif k == (top_stack + 3) then --4
  106.                 cb4:text(v)
  107.                 for k2, v2 in pairs(enabled_scripts) do
  108.                     if k == k2 then
  109.                         cb4:checked(true)
  110.                     else
  111.                         cb4:checked(false)
  112.                     end
  113.                 end
  114.             elseif k == (top_stack + 4) then --5
  115.                 cb5:text(v)
  116.                 for k2, v2 in pairs(enabled_scripts) do
  117.                     if k == k2 then
  118.                         cb5:checked(true)
  119.                     else
  120.                         cb5:checked(false)
  121.                     end
  122.                 end
  123.             elseif k == (top_stack + 5) then --6
  124.                 cb6:text(v)
  125.                 for k2, v2 in pairs(enabled_scripts) do
  126.                     if k == k2 then
  127.                         cb6:checked(true)
  128.                     else
  129.                         cb6:checked(false)
  130.                     end
  131.                 end
  132.             elseif k == (top_stack + 6) then --7
  133.                 cb7:text(v)
  134.                 for k2, v2 in pairs(enabled_scripts) do
  135.                     if k == k2 then
  136.                         cb7:checked(true)
  137.                     else
  138.                         cb7:checked(false)
  139.                     end
  140.                 end
  141.             else
  142.                 print("wtf")
  143.             end
  144.         end
  145.     end
  146. end
  147. window()
Advertisement
Add Comment
Please, Sign In to add comment