Advertisement
Chaos_Cash

snakeForPhone.lua

Dec 4th, 2024 (edited)
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 32.65 KB | None | 0 0
  1. --If control is not not working rebind your settings
  2. --For new Ideas Please leave a comment on Pastebin
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.   if not fs.exists("settings") then
  11.   game_settings=fs.open("settings","w")
  12.   game_settings.writeLine("key")
  13.   game_settings.writeLine("17")
  14.   game_settings.writeLine("key")
  15.   game_settings.writeLine("31")
  16.   game_settings.writeLine("key")
  17.   game_settings.writeLine("200")
  18.   game_settings.writeLine("key")
  19.   game_settings.writeLine("208")
  20.   game_settings.writeLine("key")
  21.   game_settings.writeLine("17")
  22.   game_settings.writeLine("key")
  23.   game_settings.writeLine("31")
  24.   game_settings.writeLine("key")
  25.   game_settings.writeLine("30")
  26.   game_settings.writeLine("key")
  27.   game_settings.writeLine("32")
  28.   game_settings.flush()
  29.   game_settings.close()
  30.   end
  31.  
  32.   if not fs.exists("highscore") then
  33.   highscore=fs.open("highscore","w")
  34.     for i=1,30 do
  35.     highscore.writeLine("0")
  36.     end
  37.   highscore.flush()
  38.   highscore.close()
  39.   end
  40.  
  41.  
  42. --
  43.  
  44.  
  45.  
  46. function swipeCheck()
  47.  
  48.     if info_1 == "mouse_click" then
  49.     lastClickPos = info_3
  50.     lastClickPosY = info_4
  51.     end
  52.    
  53.     if info_1 == "mouse_drag" and lastClickPos then
  54.         if lastClickPos - info_3 > 1 then
  55.         lastClickPos = nil
  56.         lastClickPosY = nil
  57.         return "left"
  58.         elseif lastClickPos - info_3 < -1 then
  59.         lastClickPos = nil
  60.         lastClickPosY = nil
  61.         return "right"
  62.         elseif lastClickPosY - info_4 > 1 then
  63.         lastClickPos = nil
  64.         lastClickPosY = nil
  65.         return "up"
  66.         elseif lastClickPosY - info_4 < -1 then
  67.         lastClickPos = nil
  68.         lastClickPosY = nil
  69.         return "down"
  70.         end
  71.     end
  72.  
  73. end
  74.  
  75.  
  76.  
  77. function assign_highscore()
  78. highscore=fs.open("highscore","r")
  79. pong_easy_highscore=tonumber(highscore.readLine())
  80. pong_normal_highscore=tonumber(highscore.readLine())
  81. pong_hard_highscore=tonumber(highscore.readLine())
  82. pong_extreme_highscore=tonumber(highscore.readLine())
  83. pong_insane_highscore=tonumber(highscore.readLine())
  84. click_me_easy_highscore=tonumber(highscore.readLine())
  85. click_me_normal_highscore=tonumber(highscore.readLine())
  86. click_me_hard_highscore=tonumber(highscore.readLine())
  87. click_me_extreme_highscore=tonumber(highscore.readLine())
  88. click_me_insane_highscore=tonumber(highscore.readLine())
  89. snake_easy_highscore=tonumber(highscore.readLine())
  90. snake_normal_highscore=tonumber(highscore.readLine())
  91. snake_hard_highscore=tonumber(highscore.readLine())
  92. snake_extreme_highscore=tonumber(highscore.readLine())
  93. snake_insane_highscore=tonumber(highscore.readLine())
  94. highscore.close()
  95. end
  96.  
  97.  
  98.  
  99. function assign_settings()
  100. game_settings=fs.open("settings","r")
  101. pong_p1_up_kind=game_settings.readLine()
  102. pong_p1_up_num=tonumber(game_settings.readLine())
  103. pong_p1_down_kind=game_settings.readLine()
  104. pong_p1_down_num=tonumber(game_settings.readLine())
  105. pong_p2_up_kind=game_settings.readLine()
  106. pong_p2_up_num=tonumber(game_settings.readLine())
  107. pong_p2_down_kind=game_settings.readLine()
  108. pong_p2_down_num=tonumber(game_settings.readLine())
  109. snake_up_kind=game_settings.readLine()
  110. snake_up_num=tonumber(game_settings.readLine())
  111. snake_down_kind=game_settings.readLine()
  112. snake_down_num=tonumber(game_settings.readLine())
  113. snake_left_kind=game_settings.readLine()
  114. snake_left_num=tonumber(game_settings.readLine())
  115. snake_right_kind=game_settings.readLine()
  116. snake_right_num=tonumber(game_settings.readLine())
  117. end
  118.  
  119.  
  120.  
  121. function startup_menu()
  122. term.setBackgroundColor(colors.black)
  123. term.clear()
  124. headline("Start menu")
  125. button(" Pong",16,6,25,8)
  126. button(" Exit",44,16,51,18)
  127. button(" Update",15,10,26,13)
  128. button("Click me",27,6,37,8)
  129. button("Sounds:",28,10,37,13)
  130. button("Snake",28,14,37,16)
  131. button(" Settings",15,14,26,16)
  132. term.setCursorPos(17,12)
  133. term.write("History")
  134. term.setCursorPos(31,12)
  135. term.write(sound_status.." ")
  136.     b_check=false
  137.   while true do
  138.   pull()
  139.  
  140.     if button_check(28,10,37,13) then
  141.       if sound_status=="on" then
  142.       sound_status="off"
  143.       volume=0
  144.       else
  145.       sound_status="on"
  146.       volume=1
  147.       end
  148.     term.setCursorPos(31,12)
  149.     term.write(sound_status.." ")
  150.     end
  151.  
  152.     if button_check(15,14,26,16) then
  153.     settings_pong()
  154.     end
  155.  
  156.     if button_check(28,14,37,16) then
  157.     difficulty_menu("Snake")
  158.     end
  159.  
  160.     if button_check(16,6,25,8) then
  161.     info_1=0
  162.     player_menu()
  163.     end
  164.    
  165.     if button_check(44,16,51,18) then
  166.     term.clear()
  167.     term.setCursorPos(-1,1)
  168.     error()
  169.     end
  170.    
  171.     if button_check(15,10,26,13) then
  172.     update_history()
  173.     end
  174.    
  175.     if button_check(27,6,37,8) then
  176.     difficulty_menu("Click me")
  177.     end
  178.   end
  179. end
  180.  
  181.  
  182.  
  183. function update_history()
  184. term.clear()
  185. headline("Update History")
  186. term.setCursorPos(1,4)
  187. print("1.0: Completed basic game")
  188. print("1.1: Difficulties, Better Interface, start menu")
  189. print("1.2: Singleplayer mode, Better Interface, bug fixes")
  190. print("1.3: Pong Vs bot mode, Update History, added Score")
  191. print("1.4: Added Click me, some sounds, major bug fixes")
  192. button("Home",38,16,50,18)
  193.   while 1==1 do
  194.   pull()
  195.     if button_check(38,16,50,18) then
  196.     info_1=0
  197.     startup_menu()
  198.     end
  199.   end
  200. end
  201.  
  202.  
  203.  
  204. function settings_pong()
  205. term.clear()
  206. headline("Settings")
  207. button(" Home",44,16,51,18)
  208. term.setCursorPos(1,3)
  209. term.setTextColor(colors.red)
  210. term.write("-Pong:")
  211. button(" Up P1",2,5,12,7)
  212. button(" Down P1",14,5,26,7)
  213. button(" Up P2",2,9,12,11)
  214. button(" Down P2",14,9,26,11)
  215. button(" Next",14,17,26,19)
  216.   while true do
  217.   pull()
  218.  
  219.     if button_check(44,16,51,18) then
  220.     startup_menu()
  221.     end
  222.  
  223.     if button_check(2,5,12,7) then
  224.     change_settings(1)
  225.     end
  226.  
  227.     if button_check(14,5,26,7) then
  228.     change_settings(3)
  229.     end
  230.  
  231.     if button_check(2,9,12,11) then
  232.     change_settings(5)
  233.     end
  234.  
  235.     if button_check(14,9,26,11) then
  236.     change_settings(7)
  237.     end
  238.  
  239.     if button_check(14,17,26,19) then
  240.     settings_snake()
  241.     end
  242.   end
  243. end
  244.  
  245.  
  246.  
  247.  
  248. function settings_snake()
  249. term.clear()
  250. headline("Settings")
  251. button(" Home",44,16,51,18)
  252. term.setCursorPos(1,3)
  253. term.setTextColor(colors.red)
  254. term.write("-Snake:")
  255. button(" Up",2,5,12,7)
  256. button(" Down",14,5,26,7)
  257. button(" Left",2,9,12,11)
  258. button(" Right ",14,9,26,11)
  259. button(" Last",1,17,13,19)
  260.   while true do
  261.   pull()
  262.  
  263.     if button_check(44,16,51,18) then
  264.     startup_menu()
  265.     end
  266.  
  267.     if button_check(2,5,12,7) then
  268.     change_settings(9)
  269.     end
  270.  
  271.     if button_check(14,5,26,7) then
  272.     change_settings(11)
  273.     end
  274.  
  275.     if button_check(2,9,12,11) then
  276.     change_settings(13)
  277.     end
  278.  
  279.     if button_check(14,9,26,11) then
  280.     change_settings(15)
  281.     end
  282.  
  283.     if button_check(1,17,13,19) then
  284.     settings_pong()
  285.     end
  286.   end
  287. end
  288.  
  289.  
  290.  
  291. function change_settings(change_line)
  292. os.sleep(0.5)
  293. term.setTextColor(colors.red)
  294. term.setCursorPos(10,2)
  295. term.write("Please press a key                               ")
  296. pull()
  297. old_settings={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
  298. settings_len=(fs.attributes("settings")["size"]-6)/2
  299. cur_line=1
  300. game_settings=fs.open("settings","r")
  301.   for i=1,settings_len do
  302.   old_settings[cur_line]=game_settings.readLine()
  303.   cur_line=cur_line+1
  304.   end
  305. game_settings=fs.open("settings","w")
  306. cur_line=1
  307.   for i=1,settings_len do
  308.     if cur_line~=change_line then
  309.     game_settings.writeLine(old_settings[cur_line])
  310.     cur_line=cur_line+1
  311.     else
  312.     game_settings.writeLine(info_1)
  313.     game_settings.writeLine(info_2)
  314.     cur_line=cur_line+2
  315.     end
  316.   end
  317. game_settings.flush()
  318. term.setCursorPos(10,2)
  319. term.write("The new Keybind is: ")
  320. term.setTextColor(colors.green)
  321. term.write(info_1.."  "..info_2)
  322. assign_settings()
  323. end
  324.  
  325.  
  326. function player_menu()
  327. is_bot=false
  328. term.clear()
  329. headline("Pong")
  330. button(" 1 Player",5,6,17,10)
  331. button(" 2 Players",19,6,31,10)
  332. button("Vs Bot",33,6,45,10)
  333. b_check=false
  334.   while true do
  335.   pull()
  336.     if button_check(5,6,17,10) then
  337.     is_bot=false
  338.     info_1=0
  339.     player_count=1
  340.     difficulty_menu("Pong")
  341.     end
  342.    
  343.     if button_check(19,6,31,10) then
  344.     is_bot=false
  345.     info_1=0
  346.     player_count=2
  347.     difficulty_menu("Pong")
  348.     end
  349.    
  350.     if button_check(33,6,45,10) then
  351.     info_1=0
  352.     player_count=2
  353.     is_bot=true
  354.     difficulty_menu("Pong")
  355.     end
  356.   end
  357. end
  358.  
  359.  
  360.  
  361. function minecraft_or_craftos_pc()
  362. term.clear()
  363. term.setCursorPos(7,3)
  364. term.setTextColor(colors.white)
  365. term.write("Are you using this program in ")
  366. term.setTextColor(colors.red)
  367. term.write("minecraft")
  368. term.setTextColor(colors.white)
  369. term.setCursorPos(18,4)
  370. term.write("or ")
  371. term.setTextColor(colors.red)
  372. term.write("CraftOS-PC?")
  373.  
  374. button(" Minecraft",8,8,22,10)
  375. button(" CraftOS-PC",30,8,44,10)
  376.  
  377.   while minecraft_or_pc==nil do
  378.   pull()
  379.  
  380.     if button_check(8,8,22,10) then
  381.     minecraft_or_pc="minecraft"
  382.     term.clear()
  383.     term.setCursorPos(3,3)
  384.     term.write("Please place a Speaker on top of the Computer")
  385.     sleep(3)
  386.     end
  387.  
  388.     if button_check(30,8,44,10) then
  389.     minecraft_or_pc="pc"
  390.     end
  391.   end
  392.  
  393.   if minecraft_or_pc=="pc" then
  394.   periphemu.create("top","speaker",1)
  395.   end
  396. speaker = peripheral.wrap("top")
  397. sound_status="off"
  398. volume=0
  399. end
  400.  
  401.  
  402.  
  403. function difficulty_menu(what_game)
  404. term.clear()
  405. headline(what_game)
  406. button("Easy",8,7,18,11)
  407. button("Normal",22,7,32,11)
  408. button("Hard",36,7,46,11)
  409. button(" Extreme",22,13,32,17)
  410. button("Insane",36,13,46,17)
  411. b_check=false
  412.   while true do
  413.   pull()
  414.  
  415.     if button_check(8,7,18,11) then
  416.     game_dif="easy"
  417.       if what_game=="Pong" then
  418.       info_1=0
  419.       bot_dif=6
  420.       pong(0.13)
  421.       end
  422.       if what_game=="Click me" then
  423.       click_me(1)
  424.       end
  425.       if what_game=="Snake" then
  426.       snake(0.15)
  427.       end
  428.     end
  429.  
  430.     if button_check(22,7,32,11) then
  431.     game_dif="normal"
  432.       if what_game=="Pong" then
  433.       info_1=0
  434.       bot_dif=7
  435.       pong(0.1)
  436.       end
  437.       if what_game=="Click me" then
  438.       click_me(0.8)
  439.       end
  440.       if what_game=="Snake" then
  441.       snake(0.125)
  442.       end
  443.     end
  444.  
  445.     if button_check(36,7,46,11) then
  446.     game_dif="hard"
  447.       if what_game=="Pong" then
  448.       info_1=0
  449.       bot_dif=8
  450.       pong(0.07)
  451.       end
  452.       if what_game=="Click me" then
  453.       click_me(0.6)
  454.       end
  455.       if what_game=="Snake" then
  456.       snake(0.1)
  457.       end
  458.     end
  459.  
  460.     if button_check(22,13,32,17) then
  461.     game_dif="extreme"
  462.       if what_game=="Pong" then
  463.       info_1=0
  464.       bot_dif=9
  465.       pong(0.05)
  466.       end
  467.       if what_game=="Click me" then
  468.       click_me(0.5)
  469.       end
  470.       if what_game=="Snake" then
  471.       snake(0.075)
  472.       end
  473.     end
  474.  
  475.     if button_check(36,13,46,17) then
  476.     game_dif="insane"
  477.       if what_game=="Pong" then
  478.       info_1=0
  479.       bot_dif=9
  480.       pong(0.04)
  481.       end
  482.       if what_game=="Click me" then
  483.       click_me(0.45)
  484.       end
  485.       if what_game=="Snake" then
  486.       snake(0.05)
  487.       end
  488.     end
  489.   end
  490. end
  491.  
  492.  
  493. function snake(game_speed)
  494. score=0
  495. level=1
  496. do_set_level_2=true
  497. game_running=true
  498. check_change_snake_color=0
  499. snake_len=2
  500. new_dir="up"
  501. snake_head_x=18
  502. snake_head_y=9
  503. snake_field_x1=1
  504. snake_field_y1=1
  505. snake_field_x2=36
  506. snake_field_y2=18
  507. snake_x={0,0,0,0}
  508. snake_y={0,0,0,0}
  509. do_gen_point=true
  510. term.clear()
  511. square(snake_field_x1,snake_field_y1,snake_field_x2,snake_field_y2,colors.cyan," "," ")
  512. button(" Home",44,16,51,18)
  513. print_snake()
  514. write_score()
  515. os.sleep(1)
  516.   while game_running do
  517.     if do_gen_point then
  518.     gen_point()
  519.     end
  520.   print_snake()
  521.   info_1=0
  522.   check_snake()
  523.     if do_set_level_2 and score==150 then
  524.     level=2
  525.     reset_snake()
  526.     do_set_level_2=false
  527.     line_y(12,5,14,colors.gray)
  528.     line_y(24,5,14,colors.gray)
  529.     new_dir="up"
  530.     speaker.playNote("bit",volume,20)
  531.     os.sleep(0.20)
  532.     speaker.playNote("bit",volume,22)
  533.     os.sleep(0.20)
  534.     speaker.playNote("bit",volume,24)
  535.     os.sleep(0.20)
  536.     end
  537.  
  538.   i=snake_len+1
  539.     while i>0 do
  540.     snake_x[i] = snake_x[i-1]
  541.     snake_y[i] = snake_y[i-1]
  542.     i=i-1
  543.     end
  544.   snake_x[1] = snake_head_x
  545.   snake_y[1] = snake_head_y
  546.   write_score()
  547.   clear_snake()
  548.   os.startTimer(game_speed)
  549.     while info_1~="timer" do
  550.     pull()
  551.  
  552.       if button_check(44,16,51,18) then
  553.       startup_menu()
  554.       end
  555.  
  556.  
  557.     output = swipeCheck()
  558.         if (output == "up" and snake_dir ~= "down") or (output == "down" and snake_dir ~= "up") or (output == "left" and snake_dir ~= "right") or (output == "right" and snake_dir ~= "left") then
  559.         new_dir = output
  560.         end
  561.     end
  562.  
  563.   snake_dir=new_dir
  564.     if snake_dir=="up" then
  565.     snake_head_y=snake_head_y-1
  566.     end
  567.  
  568.     if snake_dir=="down" then
  569.     snake_head_y=snake_head_y+1
  570.     end
  571.  
  572.     if snake_dir=="left" then
  573.     snake_head_x=snake_head_x-1
  574.     end
  575.  
  576.     if snake_dir=="right" then
  577.     snake_head_x=snake_head_x+1
  578.     end
  579.  
  580.    if snake_head_x==snake_field_x1 then
  581.    snake_head_x=snake_field_x2-1
  582.    end
  583.  
  584.  
  585.    if snake_head_x==snake_field_x2 then
  586.    snake_head_x=snake_field_x1+1
  587.    end
  588.  
  589.  
  590.    if snake_head_y==snake_field_y1 then
  591.    snake_head_y=snake_field_y2-1
  592.    end
  593.  
  594.  
  595.    if snake_head_y==snake_field_y2 then
  596.    snake_head_y=snake_field_y1+1
  597.    end
  598.   end
  599. end_snake()
  600.   while true do
  601.   pull()
  602.     if button_check(44,16,51,18) then
  603.     startup_menu()
  604.     end
  605.   end
  606. end
  607.  
  608.  
  609.  
  610. function end_snake()
  611.  
  612. square(snake_field_x1,snake_field_y1,snake_field_x2,snake_field_y2,colors.lightGray," "," ")
  613.   if level==2 then
  614.     line_y(12,5,14,colors.lightGray)
  615.     line_y(24,5,14,colors.lightGray)
  616.   end
  617.  
  618. i=snake_len
  619. term.setBackgroundColor(colors.lightGray)
  620. term.setCursorPos(point_pos_x,point_pos_y)
  621. term.write(" ")
  622. term.setBackgroundColor(colors.gray)
  623.   while i>0 do
  624.   term.setCursorPos(snake_x[i],snake_y[i])
  625.   term.write(" ")
  626.   i=i-1
  627.   end
  628. term.setCursorPos(snake_x[1],snake_y[1])
  629. term.setBackgroundColor(colors.red)
  630. term.write(" ")
  631.  
  632.   if game_dif=="easy" and score>snake_easy_highscore then
  633.   broke_highscore(snake_easy_highscore,11)
  634.   end
  635.   if game_dif=="normal" and score>snake_normal_highscore then
  636.   broke_highscore(snake_normal_highscore,12)
  637.   end
  638.   if game_dif=="hard" and score>snake_hard_highscore then
  639.   broke_highscore(snake_hard_highscore,13)
  640.   end
  641.   if game_dif=="extreme" and score>snake_extreme_highscore then
  642.   broke_highscore(snake_extreme_highscore,14)
  643.   end
  644.   if game_dif=="insane" and score>snake_insane_highscore then
  645.   broke_highscore(snake_insane_highscore,15)
  646.   end
  647. end
  648.  
  649.  
  650. function reset_snake()
  651. term.setBackgroundColor(colors.black)
  652. term.clear()
  653. square(snake_field_x1,snake_field_y1,snake_field_x2,snake_field_y2,colors.cyan," "," ")
  654. button(" Home",44,16,51,18)
  655. write_score()
  656.   for i=1,40 do
  657.   snake_x[i]=0
  658.   snake_y[i]=0
  659.   end
  660. snake_head_x=17
  661. snake_head_y=8
  662. snake_len=2
  663. print_snake()
  664. end
  665.  
  666.  
  667.  
  668.  
  669. function gen_point()
  670. do_for=1
  671.   while do_for>0 do
  672.   point_pos_x=math.random(snake_field_x1+1,snake_field_x2-1)
  673.   point_pos_y=math.random(snake_field_y1+1,snake_field_y2-1)
  674.   i=snake_len
  675.     while i>0 do
  676.       if point_pos_x==snake_x[i] and point_pos_y==snake_y[i] then
  677.       do_for=do_for+2
  678.       end
  679.     i=i-1
  680.     end
  681.  
  682.     if do_for<3 and (point_pos_x==12 or point_pos_x==24) and point_pos_y<15 and point_pos_y>4 then
  683.     do_for=do_for+2
  684.     end
  685.   do_for=do_for-1
  686.   end
  687. term.setBackgroundColor(colors.yellow)
  688. term.setCursorPos(point_pos_x,point_pos_y)
  689. term.write(" ")
  690. do_gen_point=false
  691. end
  692.  
  693.  
  694.  
  695.  
  696. function check_snake()
  697. i=2
  698.   while i<snake_len do
  699.     if snake_head_x==snake_x[i] and snake_head_y==snake_y[i] then
  700.     game_running=false
  701.     end
  702.   i=i+1
  703.   end
  704.  
  705.   if level==2 then
  706.     if (snake_head_x==12 or snake_head_x==24) and snake_head_y>4 and snake_head_y<15 then
  707.     game_running=false
  708.     end
  709.   end
  710.  
  711.   if snake_head_x==point_pos_x and snake_head_y==point_pos_y then
  712.   snake_len=snake_len+1
  713.   do_gen_point=true
  714.   score=score+5
  715.     if score~=150 then
  716.     speaker.playNote("bit",volume,18)
  717.     end
  718.   end
  719. end
  720.  
  721.  
  722. function clear_snake()
  723. term.setBackgroundColor(colors.black)
  724. term.setCursorPos(snake_x[snake_len+1],snake_y[snake_len+1])
  725. term.write(" ")
  726. end
  727.  
  728.  
  729. function print_snake()
  730. term.setCursorPos(snake_head_x,snake_head_y)
  731. term.setBackgroundColor(colors.lime)
  732. term.write(" ")
  733.   if check_change_snake_color>1 then
  734.   term.setCursorPos(snake_x[1],snake_y[1])
  735.   term.setBackgroundColor(colors.green)
  736.   term.write(" ")
  737.   end
  738. check_change_snake_color=check_change_snake_color+1
  739. end
  740.  
  741.  
  742.  
  743. function line_x(start_x,start_y,end_x,color)
  744. term.setBackgroundColor(color)
  745. cur_x=start_x
  746.   for i=1,end_x-start_x+1 do
  747.   term.setCursorPos(cur_x,start_y)
  748.   term.write(" ")
  749.   cur_x=cur_x+1
  750.   end
  751. end
  752.  
  753.  
  754.  
  755. function line_y(start_x,start_y,end_y,color)
  756. term.setBackgroundColor(color)
  757. cur_y=start_y
  758.   for i=1,end_y-start_y+1 do
  759.   term.setCursorPos(start_x,cur_y)
  760.   term.write(" ")
  761.   cur_y=cur_y+1
  762.   end
  763. end
  764.  
  765.  
  766.  
  767.  
  768.  
  769. function click_me(game_speed)
  770. term.clear()
  771. click_speed=game_speed
  772. game_time=10
  773. score=0
  774.  
  775.  
  776.   while game_time~=0 do
  777.   filled_square(3,3,9,6,colors.lightGray)
  778.   filled_square(11,3,17,6,colors.lightGray)
  779.   filled_square(19,3,25,6,colors.lightGray)
  780.   filled_square(3,8,9,11,colors.lightGray)
  781.   filled_square(11,8,17,11,colors.lightGray)
  782.   filled_square(19,8,25,11,colors.lightGray)
  783.   filled_square(3,13,9,16,colors.lightGray)
  784.   filled_square(11,13,17,16,colors.lightGray)
  785.   filled_square(19,13,25,16,colors.lightGray)
  786.  
  787.   old_cw=cw
  788.     while old_cw==cw do
  789.     cw=math.random(1,9)
  790.     end
  791.   ct=0
  792.  
  793.     if cw==1 then
  794.     filled_square(3,3,9,6,colors.green)
  795.     end
  796.  
  797.     if cw==2 then
  798.     filled_square(11,3,17,6,colors.green)
  799.     end
  800.  
  801.     if cw==3 then
  802.     filled_square(19,3,25,6,colors.green)
  803.     end
  804.  
  805.     if cw==4 then
  806.     filled_square(3,8,9,11,colors.green)
  807.     end
  808.  
  809.     if cw==5 then
  810.     filled_square(11,8,17,11,colors.green)
  811.     end
  812.  
  813.     if cw==6 then
  814.     filled_square(19,8,25,11,colors.green)
  815.     end
  816.  
  817.     if cw==7 then
  818.     filled_square(3,13,9,16,colors.green)
  819.     end
  820.  
  821.     if cw==8 then
  822.     filled_square(11,13,17,16,colors.green)
  823.     end
  824.  
  825.     if cw==9 then
  826.     filled_square(19,13,25,16,colors.green)
  827.     end
  828.   write_score()
  829.   write_lives_c()
  830.   timer_number=os.startTimer(game_speed)
  831.    
  832.     while info_1~="timer" and ct==0 do
  833.     pull()
  834.        
  835.       if button_check(3,3,9,6) then
  836.       ct=1
  837.       end
  838.    
  839.       if button_check(11,3,17,6) then
  840.       ct=2
  841.       end
  842.    
  843.       if button_check(19,3,25,6) then
  844.       ct=3
  845.       end
  846.    
  847.       if button_check(3,8,9,11) then
  848.       ct=4
  849.       end
  850.    
  851.       if button_check(11,8,17,11) then
  852.       ct=5
  853.       end
  854.  
  855.       if button_check(19,8,25,11) then
  856.       ct=6
  857.       end
  858.    
  859.       if button_check(3,13,9,16) then
  860.       ct=7
  861.       end
  862.  
  863.       if button_check(11,13,17,16) then
  864.       ct=8
  865.       end
  866.  
  867.       if button_check(19,13,25,16) then
  868.       ct=9
  869.       end
  870.     end
  871.    
  872.     if ct==cw then
  873.     score=score+10
  874.     speaker.playNote("bit",volume/2.5,20)
  875.     else
  876.     game_time=game_time-1
  877.     write_lives_c()
  878.       if cw==1 then
  879.       filled_square(3,3,9,6,colors.red)
  880.       end
  881.  
  882.       if cw==2 then
  883.       filled_square(11,3,17,6,colors.red)
  884.       end
  885.  
  886.       if cw==3 then
  887.       filled_square(19,3,25,6,colors.red)
  888.       end
  889.  
  890.       if cw==4 then
  891.       filled_square(3,8,9,11,colors.red)
  892.       end
  893.  
  894.       if cw==5 then
  895.       filled_square(11,8,17,11,colors.red)
  896.       end
  897.  
  898.       if cw==6 then
  899.       filled_square(19,8,25,11,colors.red)
  900.       end
  901.  
  902.       if cw==7 then
  903.       filled_square(3,13,9,16,colors.red)
  904.       end
  905.  
  906.       if cw==8 then
  907.       filled_square(11,13,17,16,colors.red)
  908.       end
  909.  
  910.       if cw==9 then
  911.       filled_square(19,13,25,16,colors.red)
  912.       end
  913.     speaker.playNote("bit",volume,0)
  914.     sleep(0.3)
  915.     end
  916.   os.cancelTimer(timer_number)
  917.   info_1=0
  918.   end
  919. sleep(0.8)
  920. term.clear()
  921. term.setCursorPos(13,9)
  922. term.write(" Your Score is: "..score)
  923. term.setTextColor(colors.white)
  924. square(11,7,34,11,colors.black,"-","|")
  925. button(" Home",44,16,51,18)
  926. button(" Play again",1,16,14,18)
  927.  
  928.   if game_dif=="easy" and score>click_me_easy_highscore then
  929.   broke_highscore(click_me_easy_highscore,6)
  930.   end
  931.   if game_dif=="normal" and score>click_me_normal_highscore then
  932.   broke_highscore(click_me_normal_highscore,7)
  933.   end
  934.   if game_dif=="hard" and score>click_me_hard_highscore then
  935.   broke_highscore(click_me_hard_highscore,8)
  936.   end
  937.   if game_dif=="extreme" and score>click_me_extreme_highscore then
  938.   broke_highscore(click_me_extreme_highscore,9)
  939.   end
  940.   if game_dif=="insane" and score>click_me_insane_highscore then
  941.   broke_highscore(click_me_insane_highscore,10)
  942.   end
  943.  
  944.   while 1==1 do
  945.   pull()
  946.  
  947.     if button_check(45,16,51,18) then
  948.     startup_menu()
  949.     end
  950.  
  951.     if button_check(1,16,13,18) then
  952.     click_me(click_speed)
  953.     end
  954.   end
  955. end
  956.  
  957.  
  958.  
  959. function write_lives_c()
  960. term.setBackgroundColor(colors.black)
  961. term.setTextColor(colors.red)
  962. term.setCursorPos(10,1)
  963.   if game_time>1 then
  964.   term.write(game_time.." ".."Lives left  ")
  965.   else
  966.   term.write(game_time.." ".."Live left  ")
  967.   end
  968. end
  969.  
  970.  
  971.  
  972. function filled_square(fill_x1,fill_y1,fill_x2,fill_y2,fill_color)
  973. term.setBackgroundColor(fill_color)
  974. curr_fill_pos_x=fill_x1
  975. curr_fill_pos_y=fill_y1
  976.   while curr_fill_pos_y~=fill_y2+1 do
  977.     while curr_fill_pos_x~=fill_x2+1 do
  978.     term.setCursorPos(curr_fill_pos_x,curr_fill_pos_y)
  979.     term.write(" ")
  980.     curr_fill_pos_x=curr_fill_pos_x+1
  981.     end
  982.   curr_fill_pos_x=fill_x1
  983.   curr_fill_pos_y=curr_fill_pos_y+1
  984.   end
  985. term.setBackgroundColor(colors.black)
  986. end
  987.  
  988.  
  989.  
  990.  
  991.  
  992. function button_check(b_check_x1,b_check_y1,b_check_x2,b_check_y2)
  993.   if info_1=="mouse_click" and info_3 > b_check_x1-1 and info_3 < b_check_x2+1 and info_4 > b_check_y1-1 and info_4 < b_check_y2+1 then
  994.   return true
  995.   else
  996.   return false
  997.   end
  998. end
  999.  
  1000.  
  1001.  
  1002. function button(button_text,button_pos_x1,button_pos_y1,button_pos_x2,button_pos_y2)
  1003. term.setTextColor(colors.green)
  1004. square(button_pos_x1,button_pos_y1,button_pos_x2,button_pos_y2,colors.black,"-","|")
  1005. term.setCursorPos(button_pos_x1-string.len(button_text)/2+(button_pos_x2-button_pos_x1)/2,button_pos_y1+(button_pos_y2-button_pos_y1)/2)
  1006. term.write(button_text)
  1007. end
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014. function headline(headline)
  1015. headline_lenght=string.len("   "..headline.."   ")
  1016. headline_pos=27-headline_lenght/2
  1017. term.setCursorPos(headline_pos,1)
  1018. term.setBackgroundColor(colors.yellow)
  1019. term.setTextColor(colors.blue)
  1020. term.write("   "..headline.."   ")
  1021. term.setBackgroundColor(colors.black)
  1022. term.setTextColor(colors.white)
  1023. end
  1024.  
  1025.  
  1026.  
  1027. function reset_players()
  1028. player_clear=2
  1029.   for i=1,12 do
  1030.   term.setCursorPos(2,player_clear)
  1031.   term.write(" ")
  1032.   term.setCursorPos(39,player_clear)
  1033.   term.write(" ")
  1034.   player_clear=player_clear+1
  1035.   end
  1036. pla1_a=6
  1037. pla1_b=9
  1038. pla2_a=6
  1039. pla2_b=9
  1040. player_1_pos(0)
  1041.   if player_count>1 then
  1042.   bot_reset=true
  1043.   player_2_pos(0)
  1044.   end
  1045. end
  1046.  
  1047.  
  1048.  
  1049. function reset_player_data()
  1050. player_1_lives=3
  1051. player_2_lives=3
  1052.  
  1053. player_1_pos_a=6
  1054. player_1_pos_b=8
  1055. pla1_a=player_1_pos_a
  1056. pla1_b=player_1_pos_b
  1057.  
  1058. player_2_pos_a=6
  1059. player_2_pos_b=8
  1060. pla2_a=player_2_pos_a
  1061. pla2_b=player_2_pos_b
  1062. end
  1063.  
  1064.  
  1065.  
  1066. function write_lives_p()
  1067. term.setCursorPos(1,16)
  1068. term.setTextColor(colors.red)
  1069.   if player_1_lives > 1 then
  1070.   term.write("Player 1: "..player_1_lives.." lives")
  1071.   else
  1072.   term.write("Player 1: "..player_1_lives.." live")
  1073.   end
  1074.   if player_count>1 then
  1075.   term.setCursorPos(1,17)
  1076.     if player_2_lives > 1 then
  1077.     term.write("Player 2: "..player_2_lives.." lives")
  1078.     else
  1079.     term.write("Player 2: "..player_2_lives.." live")
  1080.     end
  1081.   end
  1082. term.setTextColor(colors.white)
  1083. end
  1084.  
  1085.  
  1086.  
  1087. function check_ball_pos()
  1088.   if pos_x==pong_field_x1+2 then
  1089.     if pos_y==pla1_a or pos_y==pla1_a+1 or pos_y==pla1_a+2 then
  1090.     return true
  1091.     end
  1092.   end
  1093.  
  1094.   if player_count>1 then
  1095.     if pos_x==pong_field_x2-2 then
  1096.       if pos_y==pla2_a or pos_y==pla2_a+1 or pos_y==pla2_a+2 then
  1097.       return true
  1098.       end
  1099.     end
  1100.   end
  1101. end
  1102.  
  1103.  
  1104.  
  1105. function player_bot_pos(plus_min2)
  1106. if math.random(0,10) < bot_dif+1 or bot_reset then
  1107.   if plus_min2==1 then
  1108.     if pla2_a~=11 then
  1109.     term.setCursorPos(39,pla2_a)
  1110.      print(" ")
  1111.      end
  1112.   else
  1113.     if pla2_a~=2 then
  1114.     term.setCursorPos(39,pla2_b-1)
  1115.     print(" ")
  1116.     end
  1117.   end
  1118. term.setTextColor(colors.green)
  1119.   if pla2_a~=2 or plus_min2~=-1 then
  1120.     if pla2_a~=11 or plus_min2~=1 then
  1121.     pla2_a=pla2_a+plus_min2
  1122.     pla2_b=pla2_b+plus_min2
  1123.     pos2_a=pla2_a
  1124.       for i=1,3 do
  1125.       term.setCursorPos(39,pos2_a)
  1126.       term.write("|")
  1127.       pos2_a=pos2_a+1
  1128.       end
  1129.     end
  1130.   end
  1131. term.setTextColor(colors.white)
  1132. end
  1133. bot_reset=false
  1134. end
  1135.  
  1136.  
  1137.  
  1138. function player_2_pos(plus_min2)
  1139.   if is_bot then
  1140.     if do_bot_move then
  1141.     do_bot_move=false
  1142.     player_bot_pos(plus_min2)
  1143.     end
  1144.   else
  1145.  
  1146.   if plus_min2==1 then
  1147.     if pla2_a~=11 then
  1148.     term.setCursorPos(39,pla2_a)
  1149.      print(" ")
  1150.      end
  1151.   else
  1152.     if pla2_a~=2 then
  1153.     term.setCursorPos(39,pla2_b-1)
  1154.     print(" ")
  1155.     end
  1156.   end
  1157. term.setTextColor(colors.green)
  1158.   if pla2_a~=2 or plus_min2~=-1 then
  1159.     if pla2_a~=11 or plus_min2~=1 then
  1160.     pla2_a=pla2_a+plus_min2
  1161.     pla2_b=pla2_b+plus_min2
  1162.     pos2_a=pla2_a
  1163.       for i=1,3 do
  1164.       term.setCursorPos(39,pos2_a)
  1165.       term.write("|")
  1166.       pos2_a=pos2_a+1
  1167.       end
  1168.     end
  1169.   end
  1170. term.setTextColor(colors.white)
  1171. end
  1172. end
  1173.  
  1174.  
  1175.  
  1176. function player_1_pos(plus_min)
  1177.   if plus_min==1 then
  1178.     if pla1_a~=11 then
  1179.     term.setCursorPos(2,pla1_a)
  1180.     print(" ")
  1181.     end
  1182.   else
  1183.     if pla1_a~=2 then
  1184.     term.setCursorPos(2,pla1_b-1)
  1185.     print(" ")
  1186.     end
  1187.   end
  1188. term.setTextColor(colors.green)
  1189.   if pla1_a~=2 or plus_min~=-1 then
  1190.     if pla1_a~=11 or plus_min~=1 then
  1191.     pla1_a=pla1_a+plus_min
  1192.     pla1_b=pla1_b+plus_min
  1193.     pos1_a=pla1_a
  1194.       for i=1,3 do
  1195.       term.setCursorPos(2,pos1_a)
  1196.       term.write("|")
  1197.       pos1_a=pos1_a+1
  1198.       end
  1199.     end
  1200.   end
  1201. term.setTextColor(colors.white)
  1202. end
  1203.  
  1204.  
  1205.  
  1206. function square(x1,y1,x2,y2,back_color_square,symbol_square_x,symbol_square_y,text_color)
  1207. x_1=x1
  1208. y_1=y1
  1209. x_2=x2
  1210. y_2=y2
  1211.   while x_1~=x2+1 do
  1212.   term.setBackgroundColor(back_color_square)
  1213.   term.setCursorPos(x_1,y_1)
  1214.     if text_color~=nil then
  1215.     term.setTextColor(text_color)
  1216.     end
  1217.   term.write(symbol_square_x)
  1218.   x_1=x_1+1
  1219.   end
  1220.  
  1221.   while y_1~=y2-1 do
  1222.   term.setCursorPos(x_1-1,y_1+1)
  1223.   term.write(symbol_square_y)
  1224.   y_1=y_1+1
  1225.   end
  1226. x2=x2-1
  1227.   while x_2~=x1-1 do
  1228.   term.setCursorPos(x_2,y_2)
  1229.   term.write(symbol_square_x)
  1230.   x_2=x_2-1
  1231.   end
  1232.  
  1233.   while y_2~=y1+1 do
  1234.   term.setCursorPos(x_2+1,y_2-1)
  1235.   term.write(symbol_square_y)
  1236.   y_2=y_2-1
  1237.   end
  1238. term.setBackgroundColor(colors.black)
  1239. end
  1240.  
  1241.  
  1242.  
  1243. function ball()
  1244.   if ball_test~=1 then
  1245.   pos_x=20
  1246.   pos_y=7
  1247.   term.setCursorPos(pos_x,pos_y)
  1248.   term.write("o")
  1249.   reset_players()
  1250.   sleep(1)
  1251.   speaker.playNote("bit",volume*2,22)
  1252.   dir_x=math.random(0,1)
  1253.   dir_y=math.random(0,1)
  1254.   ball_test=1
  1255.   end
  1256. old_dir_x=dir_x
  1257. old_x=pos_x
  1258. old_y=pos_y
  1259.  
  1260.   if dir_x==0 then
  1261.   pos_x=pos_x+1
  1262.   else
  1263.   pos_x=pos_x-1
  1264.   end
  1265.  
  1266.   if dir_y==0 then
  1267.   pos_y=pos_y+1
  1268.   else
  1269.   pos_y=pos_y-1
  1270.   end
  1271.    
  1272.   if pos_x==pong_field_x2-2 and player_count>1 or pos_x==pong_field_x1+2 then
  1273.  
  1274.     if check_ball_pos() then
  1275.       if dir_x==0 then
  1276.       dir_x=1
  1277.       else
  1278.       dir_x=0
  1279.       end
  1280.     end
  1281.   end
  1282.  
  1283.   if pos_y==13 or pos_y==2 then
  1284.     if dir_y==0 then
  1285.     dir_y=1
  1286.     else
  1287.     dir_y=0
  1288.     end
  1289.   end
  1290. term.setCursorPos(pos_x,pos_y)
  1291. term.write("o")
  1292.  
  1293.   if pos_x==pong_field_x2-1 then
  1294.     if player_count>1 then
  1295.     clear_ball()
  1296.     player_2_lives=player_2_lives-1
  1297.     speaker.playNote("bit",volume,3)
  1298.     sleep(0.1)
  1299.     speaker.playNote("bit",volume,2)
  1300.     sleep(0.1)
  1301.     speaker.playNote("bit",volume,0)
  1302.     ball_test=0
  1303.     else
  1304.       if dir_x==0 then
  1305.       dir_x=1
  1306.       else
  1307.       dir_x=0
  1308.       end
  1309.     end
  1310.   end
  1311.  
  1312.   if pos_x==pong_field_x1+1 then
  1313.   clear_ball()
  1314.   player_1_lives=player_1_lives-1
  1315.   ball_test=0
  1316.   speaker.playNote("bit",volume,3)
  1317.   sleep(0.1)
  1318.   speaker.playNote("bit",volume,2)
  1319.   sleep(0.1)
  1320.   speaker.playNote("bit",volume,0)
  1321.   end
  1322.  
  1323. if old_dir_x~=dir_x and (player_count==2 or pos_x==pong_field_x1+2) then
  1324. speaker.playNote("bit",volume,18)
  1325. end
  1326. end
  1327.  
  1328.  
  1329.  
  1330. function pull()
  1331. info_1,info_2,info_3,info_4=os.pullEvent()
  1332. end
  1333.  
  1334.  
  1335.  
  1336. function clear_ball()
  1337. term.setCursorPos(old_x,old_y)
  1338. term.write(" ")
  1339. end
  1340.  
  1341.  
  1342.  
  1343. function write_score()
  1344. term.setBackgroundColor(colors.black)
  1345. term.setTextColor(colors.green)
  1346. term.setCursorPos(42,2)
  1347. term.write("Score:")
  1348. term.setTextColor(colors.red)
  1349. term.setCursorPos(44,4)
  1350. term.write(score)
  1351. term.setTextColor(colors.white)
  1352. end
  1353.  
  1354. function dofile(file)
  1355. local f = assert(loadfile(file))
  1356. return f()
  1357. end
  1358.  
  1359.  
  1360. function s_key()
  1361.   if info_1=="key" and (info_2==83 or info_2==31) then
  1362.   return true
  1363.   end
  1364. end
  1365.  
  1366.  
  1367.  
  1368. function w_key()
  1369.   if info_1=="key" and (info_2==87 or info_2==17) then
  1370.   return true
  1371.   end
  1372. end
  1373.  
  1374.  
  1375.  
  1376. function arrow_down_key()
  1377.   if info_1=="key" and (info_2==265 or info_2==200) then
  1378.   return true
  1379.   end
  1380. end
  1381.  
  1382.  
  1383.  
  1384. function arrow_up_key()
  1385.   if info_1=="key" and (info_2==264 or info_2==208) then
  1386.   return true
  1387.   end
  1388. end
  1389.  
  1390.  
  1391.  
  1392. function a_key()
  1393.   if info_1=="key" and info_2==30 then
  1394.   return true
  1395.   end
  1396. end
  1397.  
  1398.  
  1399.  
  1400. function d_key()
  1401.   if info_1=="key" and info_2==32 then
  1402.   return true
  1403.   end
  1404. end
  1405.  
  1406.  
  1407.  
  1408.  
  1409. function pong(ball_speed)
  1410. term.clear()
  1411.  
  1412. score=0
  1413. pong_field_x1=1
  1414. pong_field_y1=1
  1415. do_bot_move=true
  1416.  
  1417.   if player_count==2 then
  1418.   pong_field_x2=40
  1419.   pong_field_y2=14
  1420.   end
  1421.  
  1422.   if player_count==1 then
  1423.   pong_field_x2=30
  1424.   pong_field_y2=14
  1425.   end
  1426.  
  1427.  
  1428. current_ball_speed=ball_speed
  1429. reset_player_data()
  1430. square(pong_field_x1,pong_field_y1,pong_field_x2,pong_field_y2,colors.white," "," ")
  1431. player_1_pos(0)
  1432. write_score()
  1433.   if player_count>1 then
  1434.   player_2_pos(0)
  1435.   end
  1436.  
  1437.   while player_1_lives>0 and player_2_lives>0 do
  1438.   do_bot_move=true
  1439.   write_lives_p()
  1440.   ball()
  1441.   clear_ball()
  1442.   info_1=0
  1443.   write_score()
  1444.   os.startTimer(ball_speed)
  1445.     while info_1~="timer" do
  1446.     info_1=0
  1447.     pull()
  1448.  
  1449.       if info_1==pong_p1_up_kind and info_2==tonumber(pong_p1_up_num) then
  1450.       player_1_pos(-1)
  1451.       player_1_pos(-1)
  1452.       end
  1453.  
  1454.       if info_1==pong_p1_down_kind and info_2==pong_p1_down_num then
  1455.       player_1_pos(1)
  1456.       player_1_pos(1)
  1457.       end
  1458.      
  1459.       if player_count>1 and not is_bot then
  1460.         if info_1==pong_p2_up_kind and info_2==pong_p2_up_num then
  1461.         player_2_pos(-1)
  1462.         player_2_pos(-1)
  1463.         end
  1464.  
  1465.         if info_1==pong_p2_down_kind and info_2==pong_p2_down_num then
  1466.         player_2_pos(1)
  1467.         player_2_pos(1)
  1468.         end
  1469.       end
  1470.      
  1471.       if is_bot then
  1472.         if pla2_a+1 > pos_y then
  1473.         player_2_pos(-1)
  1474.         do_check=true
  1475.         check_ball_for_bot=pos_y
  1476.         end
  1477.      
  1478.         if pla2_a+1 < pos_y then
  1479.         player_2_pos(1)
  1480.         check_ball_for_bot=pos_y
  1481.         end
  1482.       end
  1483.     end
  1484.   score=score+1
  1485.   write_score()
  1486.   end
  1487. write_lives_p()
  1488. sleep(1)
  1489. term.clear()
  1490. square(13,8,35,12,colors.black,"-","|")
  1491. term.setTextColor(colors.red)
  1492. term.setCursorPos(16,10)
  1493.   if player_1_lives~=0 then
  1494.   term.write("Player 1 wins")
  1495.   else
  1496.   term.write("Player 2 wins")
  1497. end
  1498.  
  1499.   if game_dif=="easy" and score>pong_easy_highscore then
  1500.   broke_highscore(pong_easy_highscore,1)
  1501.   end
  1502.   if game_dif=="normal" and score>pong_normal_highscore then
  1503.   broke_highscore(pong_normal_highscore,2)
  1504.   end
  1505.   if game_dif=="hard" and score>pong_hard_highscore then
  1506.   broke_highscore(pong_hard_highscore,3)
  1507.   end
  1508.   if game_dif=="extreme" and score>pong_extreme_highscore then
  1509.   broke_highscore(pong_extreme_highscore,4)
  1510.   end
  1511.   if game_dif=="insane" and score>pong_insane_highscore then
  1512.   broke_highscore(pong_insane_highscore,5)
  1513.   end
  1514.  
  1515. button("Home",1,16,16,18)
  1516. button(" Play again",38,16,51,18)
  1517. b_check=false
  1518.   while not b_check do
  1519.   pull()
  1520.   b_check=button_check(1,16,16,18)
  1521.     if b_check then
  1522.     startup_menu()
  1523.     end
  1524.   b_check=button_check(38,16,51,18)
  1525.     if b_check then
  1526.     pong(current_ball_speed)
  1527.     end
  1528.   end
  1529. end
  1530.  
  1531.  
  1532.  
  1533. function broke_highscore(highscore,change_highscore)
  1534. square(10,2,38,6,colors.black,"-","|",colors.yellow)
  1535. term.setCursorPos(12,3)
  1536. term.write("You broke your highscore")
  1537. term.setCursorPos(12,4)
  1538. term.setTextColor(colors.red)
  1539. term.write("Old score:")
  1540. term.setCursorPos(12,5)
  1541. term.setTextColor(colors.green)
  1542. term.write(highscore)
  1543. term.setTextColor(colors.red)
  1544. term.setCursorPos(28,4)
  1545. term.write("New score:")
  1546. term.setCursorPos(28,5)
  1547. term.setTextColor(colors.green)
  1548. term.write(score)
  1549.  
  1550. highscore_len=fs.attributes("highscore")["size"]/2
  1551. highscore=fs.open("highscore","r")
  1552. old_highscore={0}
  1553.  
  1554.   for i=1,highscore_len do
  1555.   old_highscore[i]=highscore.readLine()
  1556.   end
  1557.  
  1558. highscore.close()
  1559. highscore=fs.open("highscore","w")
  1560.  
  1561.   for i=1,highscore_len do
  1562.     if i~=change_highscore then
  1563.     highscore.writeLine(old_highscore[i])
  1564.     else
  1565.     highscore.writeLine(score)
  1566.     end
  1567.   end
  1568.  
  1569. highscore.flush()
  1570. highscore.close()
  1571. assign_highscore()
  1572. end
  1573.  
  1574.  
  1575.  
  1576.  
  1577. minecraft_or_craftos_pc()
  1578. assign_highscore()
  1579. assign_settings()
  1580. startup_menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement