Advertisement
hbar

pickman-master

Jun 24th, 2013
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 18.14 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2. rednet.open("right")
  3. local prox = sensor.wrap("top")
  4. local wired = peripheral.wrap("bottom")
  5. local monitor, chatbox, playerDetector
  6. for k,v in pairs(wired.getNamesRemote()) do
  7.   local name = wired.getTypeRemote(v)
  8.   if name == "monitor" then
  9.     monitor = peripheral.wrap(v)
  10.   elseif name == "chat" then
  11.     chatbox = peripheral.wrap(v)
  12.   elseif name == "playerDetector" then
  13.     playerDetector = peripheral.wrap(v)
  14.   end
  15. end
  16. if prox == nil then error("unable to find proximity sensor") end
  17. if monitor == nil then error("unable to find monitor") end
  18. if not monitor.isColor() then error("not an advanced monitor") end
  19. if chatbox == nil then error("unable to find chatbox") end
  20. if playerDetector == nil then error("unable to find player detector") end
  21.  
  22. monitor.setTextScale(1)
  23. local w,h = monitor.getSize()
  24.  
  25. local maxHighScores = 20
  26.  
  27. local score = 0
  28.  
  29. local offset = {}
  30. offset.X = 17
  31. offset.Z = 14
  32.  
  33. local facings = {{-1,0},{0,1},{1,0},{0,-1}}
  34.  
  35. local ghosts =
  36. {
  37.   ["Blinky"] = {},
  38.   ["Pinky"]= {},
  39.   ["Inky"] = {},
  40.   ["Clyde"] = {}
  41. }
  42.  
  43. local logo =
  44. {
  45.   "###..............##.##........",
  46.   "#..#.#.##.#.#....#.#.#..#..###",
  47.   "###..#.#..##..##.#...#.#.#.#.#",
  48.   "#....#.##.#.#....#...#.#.#.#.#"
  49. }
  50.  
  51. local logocolor = colors.yellow
  52.  
  53. ghosts["Blinky"].state = "scatter"
  54. ghosts["Blinky"].X = 14
  55. ghosts["Blinky"].Y = 12
  56. ghosts["Blinky"].color = colors.red
  57. ghosts["Blinky"].fuel = 0
  58. ghosts["Pinky"].state = "scatter"
  59. ghosts["Pinky"].X = 14
  60. ghosts["Pinky"].Y = 12
  61. ghosts["Pinky"].fuel = 0
  62. ghosts["Pinky"].color = colors.pink
  63. ghosts["Inky"].state = "scatter"
  64. ghosts["Inky"].X = 14
  65. ghosts["Inky"].Y = 12
  66. ghosts["Inky"].fuel = 0
  67. ghosts["Inky"].color = colors.lightBlue
  68. ghosts["Clyde"].state = "scatter"
  69. ghosts["Clyde"].X = 14
  70. ghosts["Clyde"].Y = 12
  71. ghosts["Clyde"].color = colors.orange
  72. ghosts["Clyde"].fuel = 0
  73.  
  74.  
  75. local playername
  76.  
  77. local options =
  78. {
  79.   ["instakill"] = {},
  80.   ["quitonexit"] = {},
  81.   ["resetscores"] = {}
  82. }
  83.  
  84. options["instakill"].name = "Instant Death"
  85. options["instakill"].type = "boolean"
  86. options["instakill"].value = false
  87. options["instakill"].color = colors.red
  88.  
  89. options["quitonexit"].name = "Quit when leaving area"
  90. options["quitonexit"].type = "boolean"
  91. options["quitonexit"].value = true
  92. options["quitonexit"].color = colors.lime
  93.  
  94. options["resetscores"].name = "Reset scores"
  95. options["resetscores"].type = "confirm"
  96. options["resetscores"].value = false
  97. options["resetscores"].color = colors.red
  98.  
  99.  
  100. local data = {}
  101. data.X = 1
  102. data.Y = 1
  103. data.dX = -1
  104. data.dY = 0
  105. data.gold = 0
  106. data.diamonds = 0
  107. data.blinkyX = 0
  108. data.blinkyY = 0
  109. data.health = 20
  110. data.started = false
  111. data.quit = false
  112.  
  113. local maze =
  114. {
  115. "############################",
  116. "#............##............#",
  117. "#.####.#####.##.#####.####.#",
  118. "#.####.#####.##.#####.####.#",
  119. "#.####.#####.##.#####.####.#",
  120. "#..........................#",
  121. "#.####.##.########.##.####.#",
  122. "#.####.##.########.##.####.#",
  123. "#......##....##....##......#",
  124. "######.#####.##.#####.######",
  125. ".....#.#####+##+#####.#.....",
  126. ".....#.##..........##.#.....",
  127. ".....#.##.###--###.##.#.....",
  128. "######.##.#......#.##.######",
  129. "..........#......#..........",
  130. "######.##.#......#.##.######",
  131. ".....#.##.########.##.#.....",
  132. ".....#.##..........##.#.....",
  133. ".....#.##.########.##.#.....",
  134. "######.##.########.##.######",
  135. "#............##............#",
  136. "#.####.#####.##.#####.####.#",
  137. "#.####.#####+##+#####.####.#",
  138. "#...##................##...#",
  139. "###.##.##.########.##.##.###",
  140. "###.##.##.########.##.##.###",
  141. "#......##....##....##......#",
  142. "#.##########.##.##########.#",
  143. "#.##########.##.##########.#",
  144. "#..........................#",
  145. "############################"
  146. }
  147.  
  148. local printTable = function(t)
  149.   print(textutils.serialize(t))
  150. end
  151.  
  152. local tableSize = function(t)
  153.   local size = 0
  154.   for k,v in pairs(t) do
  155.     size = size + 1
  156.   end
  157.   return size
  158. end
  159.  
  160. local printLogo = function()
  161.   local posx = 5
  162.   local posy = 1
  163.   for y, line in pairs(logo) do
  164.     for x =1,line:len() do
  165.       if line:sub(x,x) == "#" then
  166.         paintutils.drawPixel(x+posx,y+posy,logocolor)
  167.       end
  168.     end
  169.   end
  170. end
  171.  
  172. local printMap = function()
  173.   term.redirect(monitor)
  174.   monitor.setBackgroundColor(colors.black)
  175.   monitor.clear()
  176.   local posx = 4
  177.   local posy = 1
  178.  
  179.   for y,line in pairs(maze) do
  180.    for x = 1,#line do
  181.      local cell = line:sub(x,x)
  182.      if cell == "#" then
  183.        paintutils.drawPixel(x+posx,y+posy,colors.blue)
  184.      elseif cell == "-"then
  185.        paintutils.drawPixel(x+posx,y+posy,colors.white)
  186.      end
  187.    end
  188.   end
  189.  
  190.   for k,v in pairs(ghosts) do
  191.     if v.state == "frightened" then
  192.       paintutils.drawPixel(v.X+posx,v.Y+posy,colors.gray)
  193.     elseif v.state == "dead" then
  194.       if k == "Blinky" then
  195.         paintutils.drawPixel(14+posx,14+posy,v.color)
  196.       elseif k == "Inky" then
  197.         paintutils.drawPixel(13+posx,15+posy,v.color)
  198.       elseif k == "Pinky" then
  199.         paintutils.drawPixel(15+posx,15+posy,v.color)
  200.       else
  201.         paintutils.drawPixel(17+posx,15+posy,v.color)
  202.       end
  203.     else
  204.       paintutils.drawPixel(v.X+posx,v.Y+posy,v.color)
  205.     end
  206.   end
  207.  
  208.   paintutils.drawPixel(data.X+posx,data.Y+posy,colors.yellow)
  209.   term.setCursorPos(5,35)
  210.   term.write("Score: "..tostring(score))
  211.   term.restore()
  212. end
  213.  
  214. local loadScores = function()
  215.   if not fs.exists("pickmanscores") then
  216.     return {}
  217.   end
  218.   local scorefile = fs.open("pickmanscores","r")
  219.   if scorefile == nil then error("unable to load scores") end
  220.   local highScores = {}
  221.   local line = scorefile.readLine()
  222.   while line ~= nil do
  223.     local score = {}
  224.     local i = line:find(" ")
  225.     score.name = line:sub(1,i-1)
  226.     score.score = tonumber(line:sub(i+1,line:len()))
  227.     table.insert(highScores,score)
  228.     line = scorefile.readLine()
  229.   end
  230.   scorefile.close()
  231.   return highScores
  232. end
  233.  
  234. local saveScores = function(scores)
  235.   table.sort(scores,function(a,b) return a.score > b.score end)
  236.   local scorefile = fs.open("pickmanscores","w")
  237.   if scorefile == nil then error("unable to open score file for saving") end
  238.   local n = math.min(tableSize(scores),maxHighScores)
  239.   for i = 1,n do
  240.     local line = scores[i].name.." "..tostring(scores[i].score)
  241.     scorefile.writeLine(line)
  242.   end
  243.   scorefile.close()
  244. end
  245.  
  246. local deleteScores = function ()
  247.   if fs.exists("pickmanscores") then fs.delete("pickmanscores") end
  248. end
  249.  
  250.  
  251.  
  252. local start, menu, mainMenu, optionsMenu, highscoreMenu, highScores
  253. local ghostnames = {}
  254.  
  255.  
  256. local printButton = function(button,color)
  257.   term.setBackgroundColor(color)
  258.   for j = 1,button.sizeY do
  259.       term.setCursorPos(button.X,button.Y+j-1)
  260.       term.write(string.rep(" ",button.sizeX))
  261.   end
  262.   term.setCursorPos(button.X+math.floor((button.sizeX-button.text:len())/2),button.Y+math.floor(button.sizeY/2))
  263.   term.write(button.text)
  264. end
  265.  
  266. local printButtons = function(buttons)
  267.   for k,v in pairs(buttons) do
  268.     printButton(v,v.color)
  269.   end
  270. end
  271.  
  272. local flashButton = function(button)
  273.   printButton(button, button.colorFlash)
  274.   --term.setCursorPos(1000,1000)
  275.   sleep(0.2)
  276.   printButton(button, button.color)
  277.   sleep(0.1)
  278. end
  279.  
  280. local waitForButton = function(buttons)
  281.   local button
  282.   while button == nil do
  283.     local e, side, X, Y = os.pullEvent("monitor_touch")
  284.     for k,v in pairs(buttons) do
  285.         if X >= v.X and X <= v.X+v.sizeX and Y >= v.Y and Y <= v.Y+v.sizeY then
  286.           button = k
  287.           break
  288.         end
  289.     end
  290.   end
  291.   return button
  292. end
  293.  
  294. local optionsToggle = function(key)
  295.   options[key].value = not options[key].value
  296.   if options[key].value then
  297.     options[key].color = colors.lime
  298.     optionsMenu[key].color = colors.lime
  299.     optionsMenu[key].colorFlash = colors.lime
  300.     optionsMenu[key].text = "On"
  301.   else
  302.     options[key].color = colors.red
  303.     optionsMenu[key].color = colors.red
  304.     optionsMenu[key].colorFlash = colors.red
  305.     optionsMenu[key].text = "Off"
  306.   end
  307. end
  308.  
  309. local confirmCheck = function(key)
  310.   local item = optionsMenu[key]
  311.   item.text = " Sure?"
  312.   item.color = colors.blue
  313.   printButtons(optionsMenu)
  314.   local e, side, X, Y = os.pullEvent("monitor_touch")
  315.   if X >= item.X and X <= item.X+item.sizeX and Y >= item.Y and Y <= item.Y+item.sizeY then
  316.     deleteScores()
  317.   end
  318.   item.text = "Delete"
  319.   item.color = colors.red
  320. end
  321.  
  322. local showOptions = function()
  323.   term.setBackgroundColor(colors.black)
  324.   term.clear()
  325.   menu = optionsMenu
  326.   local i = 0
  327.   for k,v in pairs(options) do
  328.     term.setCursorPos(5,6+8*i)
  329.     term.write(v.name)
  330.     i = i + 1
  331.   end
  332. end
  333.  
  334. local showHighScore = function()
  335.   term.setBackgroundColor(colors.black)
  336.   term.clear()
  337.   menu = highscoreMenu
  338.   highScores = loadScores()
  339.   table.sort(highScores,function(a,b) return a.score > b.score end)
  340.   local width = 28
  341.   term.setCursorPos(math.floor((w-11)/2),2)
  342.   term.write("High Scores")
  343.   term.setCursorPos(math.floor((w-width)/2),3)
  344.   term.write(string.rep(" ",width))
  345.   local n = math.min(tableSize(highScores),maxHighScores)
  346.   for i = 1,n do
  347.     term.setCursorPos(5,3+i)
  348.     local name = highScores[i].name:sub(1,10)
  349.     local score = highScores[i].score
  350.     local enum = tostring(i)
  351.     local whitespaces = width-4-name:len()-tostring(score):len()
  352.     term.write(enum.."."..string.rep(" ",4-enum:len())..name..string.rep(" ",whitespaces)..tostring(score))
  353.   end
  354.   for i=n+1,maxHighScores do
  355.     term.setCursorPos(5,3+i)
  356.     local enum = tostring(i)
  357.     local whitespaces = width-8
  358.     term.write(enum.."."..string.rep(" ",4-enum:len()).."..."..string.rep(" ",whitespaces).."0")
  359.   end
  360. end
  361.  
  362. local startGame = function()
  363.   start = true
  364. end
  365.  
  366. local showMainMenu = function()
  367.   term.setBackgroundColor(colors.black)
  368.   term.clear()
  369.   printLogo()
  370.   term.setBackgroundColor(colors.black)
  371.   menu = mainMenu
  372.   term.setCursorPos(2,h)
  373.   term.write("Fuel:")
  374.   local i = 1
  375.   for k,v in pairs(ghosts) do
  376.     term.setCursorPos(7+2*i,h)
  377.     if v.fuel > 5000 then
  378.       term.setTextColor(colors.lime)
  379.     elseif v.fuel > 500 then
  380.       term.setTextColor(colors.yellow)
  381.     else
  382.       term.setTextColor(colors.red)
  383.     end
  384.     term.write(k:sub(1,1))
  385.     i = i+1
  386.   end
  387.   term.setTextColor(colors.white)
  388. end
  389.  
  390. print("Setting up...")
  391. sleep(1)
  392. print("Finding ghosts...")
  393.  
  394. for k,v in pairs(ghosts) do
  395.   rednet.broadcast(k:lower())
  396.   local id, message, dist = rednet.receive()
  397.   message = textutils.unserialize(message)
  398.   while message.text ~= "check" do
  399.     id, message, dist = rednet.receive()
  400.     message = textutils.unserialize(message)
  401.   end
  402.   print("Found "..k.."!")
  403.   ghosts[k].fuel = message.fuel
  404.   ghostnames[id] = k
  405.   sleep(0.3)
  406. end
  407.  
  408.  
  409. print("Ghosts located!")
  410. print("Setting up menu.")
  411.  
  412. mainMenu =
  413. {
  414.   ["start"] = {},
  415.   ["options"] = {},
  416.   ["highscore"] = {}  
  417. }
  418.  
  419. mainMenu["start"].text = "Start"
  420. mainMenu["start"].X = math.floor((w-13)/2)
  421. mainMenu["start"].Y = 10
  422. mainMenu["start"].sizeX = 13
  423. mainMenu["start"].sizeY = 5
  424. mainMenu["start"].color = colors.red
  425. mainMenu["start"].colorFlash= colors.lime
  426. mainMenu["start"].func = startGame
  427.  
  428. mainMenu["options"].text = "Options"
  429. mainMenu["options"].X = math.floor((w-13)/2)
  430. mainMenu["options"].Y = 17
  431. mainMenu["options"].sizeX = 13
  432. mainMenu["options"].sizeY = 5
  433. mainMenu["options"].color = colors.red
  434. mainMenu["options"].colorFlash = colors.lime
  435. mainMenu["options"].func = showOptions
  436.  
  437. mainMenu["highscore"].text = "High Scores"
  438. mainMenu["highscore"].X = math.floor((w-13)/2)
  439. mainMenu["highscore"].Y = 24
  440. mainMenu["highscore"].sizeX = 13
  441. mainMenu["highscore"].sizeY = 5
  442. mainMenu["highscore"].color = colors.red
  443. mainMenu["highscore"].colorFlash = colors.lime
  444. mainMenu["highscore"].func = showHighScore
  445.  
  446.  
  447. optionsMenu = {}
  448.  
  449. for k,v in pairs(options) do
  450.   local tmp = {}
  451.   local n = tableSize(optionsMenu)
  452.   tmp.X = 30
  453.   tmp.Y = 5+8*n
  454.   if v.type == "boolean" then
  455.     if v.value then
  456.       tmp.text = "On"
  457.     else
  458.       tmp.text = "Off"
  459.     end
  460.     tmp.sizeX = 5
  461.     tmp.sizeY = 3
  462.     tmp.func = function() optionsToggle(k) end
  463.   elseif v.type == "confirm" then
  464.     tmp.text = "Delete"
  465.     tmp.sizeX = 8
  466.     tmp.sizeY = 3
  467.     tmp.func = function() confirmCheck(k) end
  468.   else
  469.     tmp.sizeX = 3
  470.     tmp.sizeY = 3
  471.     tmp.func = nil
  472.   end
  473.   tmp.color = v.color
  474.   tmp.colorFlash = v.color
  475.   optionsMenu[k] = tmp
  476. end
  477.  
  478. optionsMenu["back"] = {}
  479. optionsMenu["back"].text = "Back"
  480. optionsMenu["back"].X = 5
  481. optionsMenu["back"].Y = h-4
  482. optionsMenu["back"].sizeX = 8
  483. optionsMenu["back"].sizeY = 3
  484. optionsMenu["back"].color = colors.red
  485. optionsMenu["back"].colorFlash = colors.lime
  486. optionsMenu["back"].func = showMainMenu
  487.  
  488. highscoreMenu = {}
  489.  
  490. highscoreMenu["back"] = optionsMenu["back"]
  491.  
  492. term.redirect(monitor)
  493. term.clear()
  494. term.setBackgroundColor(colors.black)
  495.  
  496. --[[
  497. printLogo()
  498. term.setCursorPos(math.ceil((w-24)/2),math.floor(h/2))
  499. term.setBackgroundColor(colors.black)
  500. term.setTextColor(colors.red)
  501. term.write("Touch anywhere to start.")
  502. os.pullEvent("monitor_touch")
  503.  
  504. term.setTextColor(colors.white)
  505. ]]--
  506. showMainMenu()
  507.  
  508. while not start do
  509.   printButtons(menu)
  510.   local b = waitForButton(menu)
  511.   term.restore()
  512.   term.redirect(monitor)
  513.   flashButton(menu[b])
  514.   menu[b].func()
  515. end
  516.  
  517. term.setBackgroundColor(colors.black)
  518. term.clear()
  519. monitor.setTextScale(2)
  520. term.setCursorPos(6,3)
  521. term.write("Click the")
  522. term.setCursorPos(3,4)
  523. term.write("Player Detector")
  524. term.setCursorPos(6,5)
  525. term.write("to begin.")
  526.  
  527. local event, arg = os.pullEvent("player")
  528. playername = arg
  529.  
  530. term.clear()
  531. w,h = monitor.getSize()
  532. term.setCursorPos(6,3)
  533. term.write("Good Luck")
  534. term.setTextColor(colors.red)
  535. term.setCursorPos(math.ceil((w-playername:len())/2),4)
  536. term.write(playername)
  537. term.setTextColor(colors.white)
  538.  
  539. term.setCursorPos(5,11)
  540. term.write("Use the book")
  541. term.setCursorPos(5,12)
  542. term.write("to reach the")
  543. term.setCursorPos(4,13)
  544. term.write("starting area.")
  545.  
  546. term.setCursorPos(5,8)
  547. term.write("Get equipment")
  548. term.setCursorPos(4,9)
  549. term.write("from the chest.")
  550.  
  551. local yawToFacing = function(yaw)
  552.   local ind = math.floor(math.fmod(math.abs(yaw)+45,360)/90)
  553.   return facings[ind+1]
  554. end
  555.  
  556. local worldToGame = function(X,Z)
  557.   return {offset.Z+Z,offset.X-X}  
  558. end
  559.  
  560. local updateData = function()
  561.   local details = prox.getTargetDetails(playername)
  562.   if details ~= nil then
  563.     local pos = worldToGame(details.Position.X,details.Position.Z)
  564.     local facing = yawToFacing(details.Yaw)
  565.     data.X = pos[1]
  566.     data.Y = pos[2]
  567.     if options["quitonexit"].value and data.started then
  568.       if data.X < -2 or data.X > 32 or data.Y < 1 or data.Y > 31 then
  569.         data.quit = true
  570.       end
  571.     end
  572.  
  573.     data.dX = facing[1]
  574.     data.dY = facing[2]
  575.     local g = 0
  576.     local d = 0
  577.     if not details.IsAlive then
  578.       data.quit = true
  579.     end
  580.     if options["instakill"].value == true and details.Health < data.health then
  581.       data.quit = true
  582.     end
  583.     for k,v in pairs(details.Inventory) do
  584.       if v["Name"] == "Diamond" then
  585.         d = d+v["Size"]
  586.       elseif v["Name"] == "Gold Ore" then
  587.         g = g+v["Size"]
  588.       end
  589.     end
  590.     if g > data.gold then
  591.       score = score + 10*(g-data.gold)
  592.       data.gold = g
  593.     end
  594.     if d > data.diamonds then
  595.       chatbox.tell(playername,"Energized!",1800)
  596.       score = score + 50*(d-data.diamonds)
  597.       data.diamonds = d
  598.     end
  599.   end
  600. end
  601.  
  602. local quit = function()
  603.   chatbox.tell(playername,"Game Over! Return to main screen.", 60)
  604.   term.restore()
  605.   print("Sending quit signal to ghosts.")
  606.   local checks = {}
  607.   while tableSize(checks) < 4 do
  608.    rednet.broadcast(textutils.serialize(data))
  609.    local id, message, dist = rednet.receive(0.2)
  610.    local ghost = ghostnames[id]
  611.    if ghost ~= nil and message == "quitting" then
  612.       checks[ghost] = true
  613.       rednet.send(id, "check")
  614.    end
  615.   end
  616.   print("All ghosts report.")
  617.   term.redirect(monitor)
  618. end
  619.  
  620.  
  621. updateData()
  622. while not (math.floor(data.X) == 14 and math.floor(data.Y) == 24) do
  623.   sleep(0.3)
  624.   updateData()
  625. end
  626.  
  627. data.started = true
  628. sleep(0.5)
  629. term.clear()
  630. monitor.setTextScale(1)
  631.  
  632. chatbox.tell(playername,"Go!",60)
  633.  
  634. term.restore()
  635. print("Sending start message...")
  636. rednet.broadcast("start")
  637.  
  638.  
  639. while true do
  640.   updateData()
  641.   if data.quit then
  642.     quit()
  643.     break
  644.   end
  645.   local id, message, dist = rednet.receive(0.2)
  646.   local ghost = ghostnames[id]
  647.   if ghost ~= nil then
  648.     message = textutils.unserialize(message)
  649.     ghosts[ghost].X = message.X
  650.     ghosts[ghost].Y = message.Y
  651.   if ghost == "Blinky" then
  652.     data.blinkyX = message.X
  653.     data.blinkyY = message.Y
  654.   end
  655.     if message.state == "dead" and ghosts[ghost].state ~= "dead" then
  656.       score = score + 400
  657.     end
  658.     ghosts[ghost].state = message.state
  659.     rednet.send(id,textutils.serialize(data))
  660.   end
  661.   printMap()
  662. end
  663.  
  664. term.restore()
  665. print("Player "..playername.." finished with a score: "..tostring(score))
  666. highScores = loadScores()
  667. local tmpscore = {}
  668. tmpscore.name = playername
  669. tmpscore.score = score
  670. table.insert(highScores,tmpscore)
  671. saveScores(highScores)
  672.  
  673. term.redirect(monitor)
  674. term.setBackgroundColor(colors.black)
  675. term.clear()
  676. menu = highscoreMenu
  677. highScores = loadScores()
  678. table.sort(highScores,function(a,b) return a.score > b.score end)
  679. local width = 28
  680. term.setCursorPos(math.floor((w-11)/2),2)
  681. term.write("High Scores")
  682. term.setCursorPos(math.floor((w-width)/2),3)
  683. term.write(string.rep(" ",width))
  684. local n = math.min(tableSize(highScores),maxHighScores)
  685. for i = 1,n do
  686.   term.setTextColor(colors.white)
  687.   term.setCursorPos(5,3+i)
  688.   local name = highScores[i].name:sub(1,10)
  689.   local tmpscore = highScores[i].score
  690.   local enum = tostring(i)
  691.   local whitespaces = width-4-name:len()-tostring(score):len()
  692.   if tonumber(tmpscore) == score and name == playername:sub(1,10) then
  693.     term.setTextColor(colors.red)
  694.   end  
  695.   term.write(enum.."."..string.rep(" ",4-enum:len())..name..string.rep(" ",whitespaces)..tostring(tmpscore))
  696. end
  697. term.setTextColor(colors.white)
  698. for i=n+1,maxHighScores do
  699.   term.setCursorPos(5,3+i)
  700.   local enum = tostring(i)
  701.   local whitespaces = width-8
  702.   term.write(enum.."."..string.rep(" ",4-enum:len()).."..."..string.rep(" ",whitespaces).."0")
  703. end
  704.  
  705. term.setCursorPos(2,25)
  706. term.write("Touch anywhere to continue")
  707.  
  708. os.pullEvent("monitor_touch")
  709.  
  710. term.clear()
  711. term.restore()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement