Advertisement
ZNZNCOOP

Clicker

Dec 16th, 2015
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.41 KB | None | 0 0
  1. -- Данный код сгенерирован програмой FormsMaker
  2. -- http://computercraft.ru/topic/1044-sistema-vizualnogo-programmirovaniia-formsmaker/
  3. require("component").gpu.setResolution(80,25)
  4. forms=require("forms")
  5. forms.ignoreAll()
  6.  
  7. Buttons={}
  8.  
  9. function invert(obj)
  10.   if obj.color==0x404040 then
  11.     obj.color=0xffffff
  12.   else
  13.     obj.color=0x404040
  14.   end
  15.   obj:redraw()
  16. end
  17.  
  18. function Button1onClick(self, user)
  19.   invert(self)
  20.   for i=1,6 do
  21.     invert(Buttons[i][self.tagX])
  22.   end
  23.   for j=1,6 do
  24.     invert(Buttons[self.tagY][j])
  25.   end
  26.   for i=1,6 do
  27.     for j=1,6 do
  28.       if Buttons[i][j].color~=0xffffff then return end
  29.     end
  30.   end
  31.   Form2:setActive()  
  32. end
  33.  
  34. function Form1onCreate(self)
  35.   for i=1,6 do
  36.     Buttons[i]={}
  37.     for j=1,6 do
  38.       local B=Frame1:addButton(7*j-4,4*i-2,"",Button1onClick)
  39.       B.W=6 B.H=3 B.color=0x404040
  40.       B.tagX=j B.tagY=i
  41.       Buttons[i][j]=B
  42.     end
  43.   end
  44. end
  45.  
  46. Form1=forms.addForm()
  47. Form1.border=1
  48.  
  49. Frame1=Form1:addFrame(1,1,1)
  50. Frame1.H=25
  51. Frame1.W=46
  52.  
  53. Label1=Form1:addLabel(48,2,"Целью данной игры является\n зажечь все кнопки на поле.\nДля изменения состояния\nкнопки кликайте по ней левой\nклавишей мыши.\nОднако, вместе с ней изменятся и некоторые другие кнопки.")
  54. Label1.W=31
  55. Label1.autoSize=false
  56. Label1.H=9
  57. Label1.centered=true
  58.  
  59. function butExitonClick(self, user)
  60.   forms.stop()
  61. end
  62.  
  63. butExit=Form1:addButton(59,23,"Выход",butExitonClick)
  64.  
  65. function butClearonClick(self, user)
  66.   for i=1,6 do
  67.     for j=1,6 do
  68.       Buttons[i][j].color=0x404040
  69.     end
  70.   end
  71.   Frame1:redraw()
  72. end
  73.  
  74. butClear=Form1:addButton(59,19,"Очистить",butClearonClick)
  75.  
  76. function butNewonClick(self, user)
  77.   for i=1,6 do
  78.     for j=1,6 do
  79.       if math.random(2)==1 then
  80.         Buttons[i][j].color=0x404040
  81.       else
  82.         Buttons[i][j].color=0xffffff
  83.       end
  84.     end
  85.   end
  86.   Frame1:redraw()
  87. end
  88.  
  89. butNew=Form1:addButton(59,21,"Случайно",butNewonClick)
  90.  
  91. Form2=forms.addForm()
  92. Form2.border=2
  93. Form2.top=9
  94. Form2.H=7
  95. Form2.W=29
  96. Form2.left=23
  97.  
  98. function btnOkonClick(self, user)
  99.   Form1:setActive()
  100. end
  101.  
  102. btnOk=Form2:addButton(11,5,"Ok",btnOkonClick)
  103.  
  104. Label2=Form2:addLabel(9,3,"Задача решена")
  105. Label2.W=13
  106.  
  107. Form1onCreate(Form1)
  108. forms.run(Form1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement