Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Данный код частично сгенерирован программой FormsMaker
- -- http://computercraft.ru/topic/1044-sistema-vizualnogo-programmirovaniia-formsmaker/
- local gpu=require("component").gpu
- gpu.setResolution(112,30)
- local beep=require("computer").beep
- forms=require("forms")
- forms.ignoreAll()
- Form1=forms.addForm()
- Form1.color=8421504
- Frame1=Form1:addFrame(27,2,1)
- Frame1.H=16
- Frame1.W=60
- Frame1.color=24704
- Label11=Frame1:addLabel(7,6,"Ф е л и к С\n─────────\nМ")
- Label11.centered=true
- Label11.H=3
- Label11.color=24704
- Label11.W=12
- Label1=Frame1:addLabel(29,4,"9 8 7 6 5 4 3 2 1")
- Label1.color=24704
- for i=26,50,6 do
- local Label=Frame1:addLabel(i,5,"O\n1\n2\n3\n4\n5\n6\n7\n8\n9")
- Label.alignRight=true
- Label.autoSize=false
- Label.color=24704
- Label.H=10
- Label.W=2
- end
- Label12=Frame1:addLabel(58,5,"x\n+\n⇧\n\n⇩\n-\n:")
- Label12.centered=true
- Label12.autoSize=false
- Label12.H=7
- Label12.color=24704
- Label12.W=2
- function SlPaint(self)
- if self.tag>=0 and self.tag<=9 then gpu.set(self.X,self.Y+self.tag, "┃") end
- end
- function SlClick(self, x, y, btn, user)
- if btn==0 then
- self.tag=y-1
- self:redraw()
- end
- end
- sliders={}
- for i=1,9 do
- local slider=Frame1:addFrame(56-i*3,5,0)
- slider.H=10
- slider.W=1
- slider.paint=SlPaint
- slider.touch=SlClick
- slider.drag =SlClick
- sliders[i]=slider
- end
- Label13=Frame1:addLabel(5,15,"●")
- Label13.W=1
- Label13.color=24704
- function btClearonClick(self, user)
- for i=1,9 do
- sliders[i].tag=0
- sliders[i]:redraw()
- end
- end
- btClear=Frame1:addButton(20,14,"",btClearonClick)
- btClear.H=2
- btClear.W=4
- btClear.color=16777215
- function slDotPaint1(self)
- gpu.set(self.X+self.tag,self.Y ,"▉")
- gpu.set(self.X+self.tag,self.Y+1,"▼")
- end
- function slDotTouch1(self,x, y, btn, user)
- if btn==0 and self.tag~=x-1 then
- self.tag=x-1
- self:redraw()
- end
- end
- slDot=Frame1:addFrame(26,2,1)
- slDot.color=24704
- slDot.W=31
- slDot.H=2
- slDot.tag=0
- slDot.paint=slDotPaint1
- slDot.touch=slDotTouch1
- slDot.drag =slDotTouch1
- Carriage=Form1:addFrame(0,18,1)
- Carriage.color=8421504
- Carriage.W=93
- Carriage.tag=0
- Carriage.border=0
- Frame2=Carriage:addFrame(7,1,1)
- Frame2.H=8
- Frame2.color=24704
- Frame2.W=81
- local nums={[0]="O","1","2","3","4","5","6","7","8","9","8","7","6","5","4","3","2","1"}
- function LabelPaint(self)
- gpu.set(self.X,self.Y, nums[self.tag])
- end
- RotCount={}
- for i=1,8 do
- local Label=Frame2:addLabel(28-i*3,4,"")
- Label.autoSize=false
- Label.fontColor=0
- Label.color=16777215
- Label.W=2
- Label.paint=LabelPaint
- RotCount[i]=Label
- end
- Label9=Frame2:addLabel(4,3,"8 7 6 5 4 3 2 1")
- Label9.color=24704
- Label9.autoSize=false
- Label9.W=23
- Label10=Frame2:addLabel(37,3,"13 12 11 10 9 8 7 6 5 4 3 2 1")
- Label10.color=24704
- Label10.autoSize=false
- Label10.W=38
- ResCount={}
- for i=1,13 do
- local Label=Frame2:addLabel(76-i*3,4,"")
- Label.autoSize=false
- Label.fontColor=0
- Label.color=16777215
- Label.W=2
- Label.paint=LabelPaint
- ResCount[i]=Label
- end
- function btResClearonClick(self, user)
- for i=9,0,-1 do
- for j=1,13 do
- if ResCount[j].tag>i then
- ResCount[j].tag=i
- ResCount[j]:redraw()
- end
- end
- os.sleep(0.0)
- end
- end
- function slDotPaint(self)
- gpu.set(self.X+self.tag,self.Y , "▲")
- gpu.set(self.X+self.tag,self.Y+1, "▉")
- end
- function slDotTouch(self,x, y, btn, user)
- if btn==0 and self.tag~=x-1 then
- self.tag=x-1
- self:redraw()
- end
- end
- slRotDot=Frame2:addFrame(2,5,1)
- slRotDot.color=24704
- slRotDot.W=27
- slRotDot.H=2
- slRotDot.tag=0
- slRotDot.paint=slDotPaint
- slRotDot.touch=slDotTouch
- slRotDot.drag =slDotTouch
- slResDot=Frame2:addFrame(34,5,1)
- slResDot.color=24704
- slResDot.W=47
- slResDot.H=2
- slResDot.tag=0
- slResDot.paint=slDotPaint
- slResDot.touch=slDotTouch
- slResDot.drag =slDotTouch
- ResClear=Carriage:addButton(88,2,"",btResClearonClick)
- ResClear.H=5
- ResClear.W=3
- ResClear.color=16777215
- function btRotClearonClick(self, user)
- for i=18,0,-1 do
- for j=1,8 do
- if RotCount[j].tag>i then
- RotCount[j].tag=i
- RotCount[j]:redraw()
- end
- end
- os.sleep(0.0)
- end
- end
- RotClear=Carriage:addButton(4,2,"",btRotClearonClick)
- RotClear.color=16777215
- RotClear.W=3
- RotClear.H=5
- CarMove=Carriage:addButton(33,9,"")
- CarMove.H=2
- function CarMove:touch(x, y, btn, user)
- if btn==0 then
- CarMove.tag=x
- end
- end
- function CarMove:drag(x, y, btn, user)
- if x<=CarMove.tag-3 and Carriage.tag>0 then
- Carriage.tag=Carriage.tag-1
- Carriage.left=Carriage.tag*3
- Carriage:redraw()
- end
- if x>=CarMove.tag+3 and Carriage.tag<7 then
- Carriage.tag=Carriage.tag+1
- Carriage.left=Carriage.tag*3
- Carriage:redraw()
- end
- end
- function btUponClick(self, user)
- for i=1,20 do
- for j=1,9 do
- sliders[j].tag=(sliders[j].tag<19) and sliders[j].tag+1 or 0
- sliders[j]:redraw()
- local n=j+Carriage.tag
- if n<=13 then
- if i<11 and sliders[j].tag>10 then
- ResCount[n].tag=ResCount[n].tag+1
- if ResCount[n].tag>9 then ResCount[n].tag=0 ResCount[n].carry=true end
- ResCount[n]:redraw()
- end
- end
- end
- os.sleep(0.0)
- end
- for j=1,13 do
- if ResCount[j].carry then
- ResCount[j].carry=false
- if j<13 then
- ResCount[j+1].tag=ResCount[j+1].tag+1
- if ResCount[j+1].tag>9 then ResCount[j+1].tag=0 ResCount[j+1].carry=true end
- ResCount[j+1]:redraw()
- os.sleep(0.0)
- else
- beep()
- end
- end
- end
- RotCount[Carriage.tag+1].tag=RotCount[Carriage.tag+1].tag+1
- if RotCount[Carriage.tag+1].tag>17 then RotCount[Carriage.tag+1].tag=0 end
- RotCount[Carriage.tag+1]:redraw()
- end
- btUp=Form1:addButton(87,5,"",btUponClick)
- btUp.H=4
- btUp.W=3
- function btDownonClick(self, user)
- for i=1,20 do
- for j=1,9 do
- sliders[j].tag=(sliders[j].tag>-10) and sliders[j].tag-1 or 9
- sliders[j]:redraw()
- local n=j+Carriage.tag
- if n<=13 then
- if i<11 and sliders[j].tag>=0 then
- ResCount[n].tag=ResCount[n].tag-1
- if ResCount[n].tag<0 then ResCount[n].tag=9 ResCount[n].carry=true end
- ResCount[n]:redraw()
- end
- end
- end
- os.sleep(0.0)
- end
- for j=1,13 do
- if ResCount[j].carry then
- ResCount[j].carry=false
- if j<13 then
- ResCount[j+1].tag=ResCount[j+1].tag-1
- if ResCount[j+1].tag<0 then ResCount[j+1].tag=9 ResCount[j+1].carry=true end
- ResCount[j+1]:redraw()
- os.sleep(0.0)
- else
- beep()
- end
- end
- end
- RotCount[Carriage.tag+1].tag=RotCount[Carriage.tag+1].tag-1
- if RotCount[Carriage.tag+1].tag<0 then RotCount[Carriage.tag+1].tag=17 end
- RotCount[Carriage.tag+1]:redraw()
- end
- btDown=Form1:addButton(87,10,"",btDownonClick)
- btDown.W=3
- btDown.H=4
- Button5=Form1:addButton(110,1,"X",forms.stop)
- Button5.W=3
- forms.run(Form1)
- require("term").clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement