Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Данный код сгенерирован програмой FormsMaker
- -- http://computercraft.ru/topic/1044-sistema-vizualnogo-programmirovaniia-formsmaker/
- require("component").gpu.setResolution(80,25)
- forms=require("forms")
- forms.ignoreAll()
- Buttons={}
- function invert(obj)
- if obj.color==0x404040 then
- obj.color=0xffffff
- else
- obj.color=0x404040
- end
- obj:redraw()
- end
- function Button1onClick(self, user)
- invert(self)
- for i=1,6 do
- invert(Buttons[i][self.tagX])
- end
- for j=1,6 do
- invert(Buttons[self.tagY][j])
- end
- for i=1,6 do
- for j=1,6 do
- if Buttons[i][j].color~=0xffffff then return end
- end
- end
- Form2:setActive()
- end
- function Form1onCreate(self)
- for i=1,6 do
- Buttons[i]={}
- for j=1,6 do
- local B=Frame1:addButton(7*j-4,4*i-2,"",Button1onClick)
- B.W=6 B.H=3 B.color=0x404040
- B.tagX=j B.tagY=i
- Buttons[i][j]=B
- end
- end
- end
- Form1=forms.addForm()
- Form1.border=1
- Frame1=Form1:addFrame(1,1,1)
- Frame1.H=25
- Frame1.W=46
- Label1=Form1:addLabel(48,2,"Целью данной игры является\n зажечь все кнопки на поле.\nДля изменения состояния\nкнопки кликайте по ней левой\nклавишей мыши.\nОднако, вместе с ней изменятся и некоторые другие кнопки.")
- Label1.W=31
- Label1.autoSize=false
- Label1.H=9
- Label1.centered=true
- function butExitonClick(self, user)
- forms.stop()
- end
- butExit=Form1:addButton(59,23,"Выход",butExitonClick)
- function butClearonClick(self, user)
- for i=1,6 do
- for j=1,6 do
- Buttons[i][j].color=0x404040
- end
- end
- Frame1:redraw()
- end
- butClear=Form1:addButton(59,19,"Очистить",butClearonClick)
- function butNewonClick(self, user)
- for i=1,6 do
- for j=1,6 do
- if math.random(2)==1 then
- Buttons[i][j].color=0x404040
- else
- Buttons[i][j].color=0xffffff
- end
- end
- end
- Frame1:redraw()
- end
- butNew=Form1:addButton(59,21,"Случайно",butNewonClick)
- Form2=forms.addForm()
- Form2.border=2
- Form2.top=9
- Form2.H=7
- Form2.W=29
- Form2.left=23
- function btnOkonClick(self, user)
- Form1:setActive()
- end
- btnOk=Form2:addButton(11,5,"Ok",btnOkonClick)
- Label2=Form2:addLabel(9,3,"Задача решена")
- Label2.W=13
- Form1onCreate(Form1)
- forms.run(Form1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement