ZNZNCOOP

felix_m

Sep 8th, 2017
112
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Данный код частично сгенерирован программой FormsMaker
  2. -- http://computercraft.ru/topic/1044-sistema-vizualnogo-programmirovaniia-formsmaker/
  3. local gpu=require("component").gpu
  4. gpu.setResolution(112,30)
  5. local beep=require("computer").beep
  6. forms=require("forms")
  7. forms.ignoreAll()
  8.  
  9. Form1=forms.addForm()
  10. Form1.color=8421504
  11.  
  12. Frame1=Form1:addFrame(27,2,1)
  13. Frame1.H=16
  14. Frame1.W=60
  15. Frame1.color=24704
  16.  
  17. Label11=Frame1:addLabel(7,6,"Ф е л и к С\n─────────\nМ")
  18. Label11.centered=true
  19. Label11.H=3
  20. Label11.color=24704
  21. Label11.W=12
  22.  
  23. Label1=Frame1:addLabel(29,4,"9  8  7  6  5  4  3  2  1")
  24. Label1.color=24704
  25.  
  26. for i=26,50,6 do
  27.   local Label=Frame1:addLabel(i,5,"O\n\n\n\n\n\n\n\n\n9")
  28.   Label.alignRight=true
  29.   Label.autoSize=false
  30.   Label.color=24704
  31.   Label.H=10
  32.   Label.W=2
  33. end
  34.  
  35. Label12=Frame1:addLabel(58,5,"x\n+\n\n\n\n-\n:")
  36. Label12.centered=true
  37. Label12.autoSize=false
  38. Label12.H=7
  39. Label12.color=24704
  40. Label12.W=2
  41.  
  42. function SlPaint(self)
  43.   if self.tag>=0 and self.tag<=9 then gpu.set(self.X,self.Y+self.tag, "┃") end
  44. end
  45.  
  46. function SlClick(self, x, y, btn, user)
  47.   if btn==0 then
  48.     self.tag=y-1
  49.     self:redraw()
  50.   end
  51. end
  52.  
  53. sliders={}
  54. for i=1,9 do
  55.   local slider=Frame1:addFrame(56-i*3,5,0)
  56.   slider.H=10
  57.   slider.W=1
  58.   slider.paint=SlPaint
  59.   slider.touch=SlClick
  60.   slider.drag =SlClick
  61.   sliders[i]=slider
  62. end
  63.  
  64. Label13=Frame1:addLabel(5,15,"●")
  65. Label13.W=1
  66. Label13.color=24704
  67.  
  68. function btClearonClick(self, user)
  69.   for i=1,9 do
  70.     sliders[i].tag=0
  71.     sliders[i]:redraw()
  72.   end
  73. end
  74.  
  75. btClear=Frame1:addButton(20,14,"",btClearonClick)
  76. btClear.H=2
  77. btClear.W=4
  78. btClear.color=16777215
  79.  
  80. function slDotPaint1(self)
  81.   gpu.set(self.X+self.tag,self.Y  ,"▉")
  82.   gpu.set(self.X+self.tag,self.Y+1,"▼")
  83. end
  84.  
  85. function slDotTouch1(self,x, y, btn, user)
  86.   if btn==0 and self.tag~=x-1 then
  87.     self.tag=x-1
  88.     self:redraw()
  89.   end
  90. end
  91.  
  92. slDot=Frame1:addFrame(26,2,1)
  93. slDot.color=24704
  94. slDot.W=31
  95. slDot.H=2
  96. slDot.tag=0
  97. slDot.paint=slDotPaint1
  98. slDot.touch=slDotTouch1
  99. slDot.drag =slDotTouch1
  100.  
  101.  
  102. Carriage=Form1:addFrame(0,18,1)
  103. Carriage.color=8421504
  104. Carriage.W=93
  105. Carriage.tag=0
  106. Carriage.border=0
  107.  
  108. Frame2=Carriage:addFrame(7,1,1)
  109. Frame2.H=8
  110. Frame2.color=24704
  111. Frame2.W=81
  112.  
  113. local nums={[0]="O","1","2","3","4","5","6","7","8","9","8","7","6","5","4","3","2","1"}
  114. function LabelPaint(self)
  115.   gpu.set(self.X,self.Y, nums[self.tag])
  116. end
  117.  
  118. RotCount={}
  119. for i=1,8 do
  120.   local Label=Frame2:addLabel(28-i*3,4,"")
  121.   Label.autoSize=false
  122.   Label.fontColor=0
  123.   Label.color=16777215
  124.   Label.W=2
  125.   Label.paint=LabelPaint
  126.   RotCount[i]=Label
  127. end
  128.  
  129. Label9=Frame2:addLabel(4,3,"8 7 6 5 4 3 2 1")
  130. Label9.color=24704
  131. Label9.autoSize=false
  132. Label9.W=23
  133.  
  134. Label10=Frame2:addLabel(37,3,"13 12 11 10 9 8 7 6 5 4 3 2 1")
  135. Label10.color=24704
  136. Label10.autoSize=false
  137. Label10.W=38
  138.  
  139. ResCount={}
  140. for i=1,13 do
  141.   local Label=Frame2:addLabel(76-i*3,4,"")
  142.   Label.autoSize=false
  143.   Label.fontColor=0
  144.   Label.color=16777215
  145.   Label.W=2
  146.   Label.paint=LabelPaint
  147.   ResCount[i]=Label
  148. end
  149.  
  150. function btResClearonClick(self, user)
  151.   for i=9,0,-1 do
  152.     for j=1,13 do
  153.       if ResCount[j].tag>i then
  154.         ResCount[j].tag=i
  155.         ResCount[j]:redraw()
  156.       end
  157.     end
  158.     os.sleep(0.0)
  159.   end
  160. end
  161.  
  162.  
  163. function slDotPaint(self)
  164.   gpu.set(self.X+self.tag,self.Y  , "▲")
  165.   gpu.set(self.X+self.tag,self.Y+1, "▉")
  166. end
  167.  
  168. function slDotTouch(self,x, y, btn, user)
  169.   if btn==0 and self.tag~=x-1 then
  170.     self.tag=x-1
  171.     self:redraw()
  172.   end
  173. end
  174.  
  175. slRotDot=Frame2:addFrame(2,5,1)
  176. slRotDot.color=24704
  177. slRotDot.W=27
  178. slRotDot.H=2
  179. slRotDot.tag=0
  180. slRotDot.paint=slDotPaint
  181. slRotDot.touch=slDotTouch
  182. slRotDot.drag =slDotTouch
  183.  
  184. slResDot=Frame2:addFrame(34,5,1)
  185. slResDot.color=24704
  186. slResDot.W=47
  187. slResDot.H=2
  188. slResDot.tag=0
  189. slResDot.paint=slDotPaint
  190. slResDot.touch=slDotTouch
  191. slResDot.drag =slDotTouch
  192.  
  193. ResClear=Carriage:addButton(88,2,"",btResClearonClick)
  194. ResClear.H=5
  195. ResClear.W=3
  196. ResClear.color=16777215
  197.  
  198. function btRotClearonClick(self, user)
  199.   for i=18,0,-1 do
  200.     for j=1,8 do
  201.       if RotCount[j].tag>i then
  202.         RotCount[j].tag=i
  203.         RotCount[j]:redraw()
  204.       end
  205.     end
  206.     os.sleep(0.0)
  207.   end
  208. end
  209.  
  210. RotClear=Carriage:addButton(4,2,"",btRotClearonClick)
  211. RotClear.color=16777215
  212. RotClear.W=3
  213. RotClear.H=5
  214.  
  215. CarMove=Carriage:addButton(33,9,"")
  216. CarMove.H=2
  217.  
  218. function CarMove:touch(x, y, btn, user)
  219.   if btn==0 then
  220.     CarMove.tag=x
  221.   end
  222. end
  223.  
  224. function CarMove:drag(x, y, btn, user)
  225.   if x<=CarMove.tag-3 and Carriage.tag>0 then
  226.     Carriage.tag=Carriage.tag-1
  227.     Carriage.left=Carriage.tag*3
  228.     Carriage:redraw()
  229.   end
  230.   if x>=CarMove.tag+3 and Carriage.tag<7 then
  231.     Carriage.tag=Carriage.tag+1
  232.     Carriage.left=Carriage.tag*3
  233.     Carriage:redraw()
  234.   end
  235. end
  236.  
  237. function btUponClick(self, user)
  238.   for i=1,20 do
  239.     for j=1,9 do
  240.       sliders[j].tag=(sliders[j].tag<19) and sliders[j].tag+1 or 0
  241.       sliders[j]:redraw()
  242.       local n=j+Carriage.tag
  243.       if n<=13 then
  244.         if i<11 and sliders[j].tag>10 then
  245.           ResCount[n].tag=ResCount[n].tag+1
  246.           if ResCount[n].tag>9 then ResCount[n].tag=0 ResCount[n].carry=true end
  247.           ResCount[n]:redraw()
  248.         end
  249.       end
  250.     end
  251.     os.sleep(0.0)
  252.   end
  253.   for j=1,13 do
  254.     if ResCount[j].carry then
  255.       ResCount[j].carry=false
  256.       if j<13 then
  257.         ResCount[j+1].tag=ResCount[j+1].tag+1
  258.         if ResCount[j+1].tag>9 then ResCount[j+1].tag=0 ResCount[j+1].carry=true end
  259.         ResCount[j+1]:redraw()
  260.         os.sleep(0.0)
  261.       else
  262.         beep()
  263.       end
  264.     end
  265.   end
  266.   RotCount[Carriage.tag+1].tag=RotCount[Carriage.tag+1].tag+1
  267.   if RotCount[Carriage.tag+1].tag>17 then RotCount[Carriage.tag+1].tag=0 end
  268.   RotCount[Carriage.tag+1]:redraw()
  269. end
  270.  
  271. btUp=Form1:addButton(87,5,"",btUponClick)
  272. btUp.H=4
  273. btUp.W=3
  274.  
  275. function btDownonClick(self, user)
  276.   for i=1,20 do
  277.     for j=1,9 do
  278.       sliders[j].tag=(sliders[j].tag>-10) and sliders[j].tag-1 or 9
  279.       sliders[j]:redraw()
  280.       local n=j+Carriage.tag
  281.       if n<=13 then
  282.         if i<11 and sliders[j].tag>=0 then
  283.           ResCount[n].tag=ResCount[n].tag-1
  284.           if ResCount[n].tag<0 then ResCount[n].tag=9 ResCount[n].carry=true end
  285.           ResCount[n]:redraw()
  286.         end
  287.       end
  288.     end
  289.     os.sleep(0.0)
  290.   end  
  291.   for j=1,13 do
  292.     if ResCount[j].carry then
  293.       ResCount[j].carry=false
  294.       if j<13 then
  295.         ResCount[j+1].tag=ResCount[j+1].tag-1
  296.         if ResCount[j+1].tag<0 then ResCount[j+1].tag=9 ResCount[j+1].carry=true end
  297.         ResCount[j+1]:redraw()
  298.         os.sleep(0.0)
  299.       else
  300.         beep()
  301.       end
  302.     end
  303.   end
  304.   RotCount[Carriage.tag+1].tag=RotCount[Carriage.tag+1].tag-1
  305.   if RotCount[Carriage.tag+1].tag<0 then RotCount[Carriage.tag+1].tag=17 end
  306.   RotCount[Carriage.tag+1]:redraw()
  307. end
  308.  
  309. btDown=Form1:addButton(87,10,"",btDownonClick)
  310. btDown.W=3
  311. btDown.H=4
  312.  
  313. Button5=Form1:addButton(110,1,"X",forms.stop)
  314. Button5.W=3
  315.  
  316. forms.run(Form1)
  317.  
  318. require("term").clear()
RAW Paste Data