MagmaLP

SMF-Overclocking-List+Program

Aug 24th, 2024 (edited)
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.02 KB | None | 0 0
  1.  
  2. -- Farbcodes für die Ausgabe
  3. local colors = {
  4.             Aes = colors.red,    
  5.          Dollar = colors.yellow,    
  6.     Overclocker = colors.blue,         
  7.         Coupons = colours.white,       
  8.            blue = colors.lightBlue,    
  9.             red = colors.red,          
  10.            gold = colors.yellow,
  11.           black = colors.black
  12. }
  13.  
  14. -- Daten als lange Zeichenkette
  15. local data_string = [[
  16. 1 1 200 2 0
  17. 2 2 210 4 0
  18. 3 2 220 6 0
  19. 4 3 230 8 0
  20. 5 3 240 10 0
  21. 6 4 250 12 0
  22. 7 4 260 14 0
  23. 8 5 270 16 0
  24. 9 5 280 18 0
  25. 10 6 290 20 0
  26. 11 6 300 22 0
  27. 12 7 310 24 0
  28. 13 7 320 26 0
  29. 14 8 330 28 0
  30. 15 8 340 30 0
  31. 16 9 350 32 0
  32. 17 9 360 34 0
  33. 18 10 370 36 0
  34. 19 10 380 38 0
  35. 20 11 390 40 0
  36. 21 11 400 42 0
  37. 22 12 410 44 0
  38. 23 12 420 46 0
  39. 24 13 430 48 0
  40. 25 13 440 50 0
  41. 26 14 450 52 0
  42. 27 14 460 54 0
  43. 28 15 470 56 0
  44. 29 15 480 58 0
  45. 30 16 490 60 0
  46. 31 16 500 62 0
  47. 32 17 510 64 0
  48. 33 17 520 66 0
  49. 34 18 530 68 0
  50. 35 18 540 70 0
  51. 36 19 550 72 0
  52. 37 19 560 74 0
  53. 38 20 570 76 0
  54. 39 20 580 78 0
  55. 40 21 590 80 0
  56. 41 21 600 82 0
  57. 42 22 610 84 0
  58. 43 22 620 86 0
  59. 44 23 630 88 0
  60. 45 23 640 90 0
  61. 46 24 650 92 0
  62. 47 24 660 94 0
  63. 48 25 670 96 0
  64. 49 25 680 98 0
  65. 50 26 690 100 0
  66. 51 26 700 102 0
  67. 52 27 710 104 0
  68. 53 27 720 106 0
  69. 54 28 730 108 0
  70. 55 28 740 110 0
  71. 56 29 750 112 0
  72. 57 29 760 114 0
  73. 58 30 770 116 0
  74. 59 30 780 118 0
  75. 60 31 790 120 0
  76. 61 31 800 122 0
  77. 62 32 810 124 0
  78. 63 32 820 126 0
  79. 64 33 830 128 0
  80. 65 33 840 130 0
  81. 66 34 850 132 0
  82. 67 34 860 134 0
  83. 68 35 870 136 0
  84. 69 35 880 138 0
  85. 70 36 890 140 0
  86. 71 36 900 142 0
  87. 72 37 910 144 0
  88. 73 37 920 146 0
  89. 74 38 930 148 0
  90. 75 38 940 150 0
  91. 76 39 950 152 0
  92. 77 39 960 154 0
  93. 78 40 970 156 0
  94. 79 40 980 158 0
  95. 80 41 990 160 0
  96. 81 41 1000 162 0
  97. 82 42 1010 164 0
  98. 83 42 1020 166 0
  99. 84 43 1030 168 0
  100. 85 43 1040 170 0
  101. 86 44 1050 172 0
  102. 87 44 1060 174 0
  103. 88 45 1070 176 0
  104. 89 45 1080 178 0
  105. 90 46 1090 180 0
  106. 91 46 1100 182 0
  107. 92 47 1110 184 0
  108. 93 47 1120 186 0
  109. 94 48 1130 188 0
  110. 95 48 1140 190 0
  111. 96 49 1150 192 0
  112. 97 49 1160 194 0
  113. 98 50 1170 196 0
  114. 99 50 1180 198 0
  115. 100 51 1190 200 0
  116. 101 51 1200 202 1
  117. 102 52 1210 204 1
  118. 103 52 1220 206 1
  119. 104 53 1230 208 1
  120. 105 53 1240 210 1
  121. 106 54 1250 212 1
  122. 107 54 1260 214 1
  123. 108 55 1270 216 1
  124. 109 55 1280 218 1
  125. 110 56 1290 220 1
  126. 111 56 1300 222 1
  127. 112 57 1310 224 1
  128. 113 57 1320 226 1
  129. 114 58 1330 228 1
  130. 115 58 1340 230 1
  131. 116 59 1350 232 1
  132. 117 59 1360 234 1
  133. 118 60 1370 236 1
  134. 119 60 1380 238 1
  135. 120 61 1390 240 1
  136. 121 61 1400 242 1
  137. 122 62 1410 244 1
  138. 123 62 1420 246 1
  139. 124 63 1430 248 1
  140. 125 63 1440 250 1
  141. 126 64 1450 252 1
  142. 127 64 1460 254 1
  143. 128 65 1470 256 1
  144. 129 65 1480 258 1
  145. 130 66 1490 260 1
  146. 131 66 1500 262 1
  147. 132 67 1510 264 1
  148. 133 67 1520 266 1
  149. 134 68 1530 268 1
  150. 135 68 1540 270 1
  151. 136 69 1550 272 1
  152. 137 69 1560 274 1
  153. 138 70 1570 276 1
  154. 139 70 1580 278 1
  155. 140 71 1590 280 1
  156. 141 71 1600 282 1
  157. 142 72 1610 284 1
  158. 143 72 1620 286 1
  159. 144 73 1630 288 1
  160. 145 73 1640 290 1
  161. 146 74 1650 292 1
  162. 147 74 1660 294 1
  163. 148 75 1670 296 1
  164. 149 75 1680 298 1
  165. 150 76 1690 300 1
  166. ]]
  167.  
  168.  
  169.  
  170. -- Funktion zum Parsen der Daten
  171. local function parseData(data_string)
  172.     local data = {}
  173.     for line in data_string:gmatch("[^\r\n]+") do
  174.         local level, Aes, Dollar, Overclocker, Coupons = line:match("(%d+) (%d+) (%d+) (%d+) (%d+)")
  175.         if level then
  176.             table.insert(data, {
  177.                 level = tonumber(level),
  178.                 Aes = tonumber(Aes),
  179.                 Dollar = tonumber(Dollar),
  180.                 Overclocker = tonumber(Overclocker),
  181.                 Coupons = tonumber(Coupons),
  182.             })
  183.         end
  184.     end
  185.     return data
  186. end
  187.  
  188. -- Datenliste aus der Zeichenkette erzeugen
  189. local dust_list = parseData(data_string)
  190.  
  191. -- Funktion zum Berechnen der benötigten Ressourcen von einem Startlevel bis zu einem Ziellevel
  192. local function calculateResources(start_level, end_level)
  193.     local total_resources = {Aes = 0, Dollar = 0, Overclocker = 0, Coupons = 0}
  194.    
  195.     -- Gehe durch alle Level in der Liste
  196.     for _, entry in ipairs(dust_list) do
  197.         local level, Aes, Dollar, Overclocker, Coupons = entry.level, entry.Aes, entry.Dollar, entry.Overclocker, entry.Coupons
  198.         if level > start_level and level <= end_level then
  199.             total_resources.Aes = total_resources.Aes + Aes
  200.             total_resources.Dollar = total_resources.Dollar + Dollar
  201.             total_resources.Overclocker = total_resources.Overclocker + Overclocker
  202.             total_resources.Coupons = total_resources.Coupons + Coupons
  203.         end
  204.     end
  205.  
  206.     return total_resources
  207. end
  208.  
  209. -- Funktion zum Anzeigen der benötigten Ressourcen
  210. local function displayTotalResources(start_level, end_level, resources)
  211. term.setTextColor(colours.lightBlue)
  212.     print("Benötigte Ressourcen von Level " .. (start_level + 1) .. " bis Level " .. end_level .. ":")
  213.     print(" ")
  214.  
  215.     -- Funktion zum Setzen der Farbe und Ausgabe der Ressource
  216.     local function printResource(name, value)
  217.         local color = colors[name]
  218.         if color then
  219.             term.setTextColor(color)
  220.         else
  221.                     -- Fallback auf Weiß, wenn keine Farbe definiert ist
  222.         end
  223.         print(string.format("%s: %d", name, value))
  224.         term.setTextColor(colours.white) -- Setze die Textfarbe nach jeder Ausgabe zurück
  225.     end
  226.  
  227.     -- Ausgabe der Ressourcen in Farben und untereinander
  228.     term.setTextColor(colors.red) -- Setze die Farbe für die Zahlen auf Rot
  229.     printResource("Aes", resources.Aes)
  230.     printResource("Dollar", resources.Dollar)
  231.     printResource("Overclocker", resources.Overclocker)
  232.     printResource("Coupons", resources.Coupons)
  233.     term.setTextColor(colours.white) -- Setze die Textfarbe nach der letzten Ausgabe zurück
  234. end
  235.  
  236. while true do
  237.     -- Hauptprogramm
  238.     term.setBackgroundColor(colors.black)
  239.     term.clear()
  240.     term.setCursorPos(13,2)
  241.     term.setTextColor(colors.gold)
  242.     print("SMF Übertaktungs Rechner")
  243.     term.setCursorPos(13,3)
  244.     print("~~~~~~~~~~~~~~~~~~~~~~~~")
  245.     term.setCursorPos(1,5)
  246.     term.setTextColor(colors.blue) -- Setze die Farbe für die Eingabeaufforderungen auf Gold
  247.     print("Gib dein aktuelles Level ein:")
  248.     term.setTextColor(colours.white) -- Setze die Textfarbe nach der Eingabeaufforderung zurück
  249.     local start_input = read()
  250.     local start_level = tonumber(start_input)
  251.     term.setCursorPos(1,5)
  252.     print("                             ")
  253.     term.setCursorPos(1,6)
  254.     print("                             ")
  255.     term.setCursorPos(1,5)
  256.     term.setTextColor(colors.blue) -- Setze die Farbe für die Eingabeaufforderung auf Gold
  257.     print("Gib das Ziel-Level ein:")
  258.     term.setTextColor(colours.white) -- Setze die Textfarbe nach der Eingabeaufforderung zurück
  259.     local end_input = read()
  260.     local end_level = tonumber(end_input)
  261.     term.setCursorPos(1,5)
  262.     print("                             ")
  263.     term.setCursorPos(1,6)
  264.     print("                             ")
  265.     term.setCursorPos(1,5)
  266.  
  267.     if start_level and end_level and start_level < end_level then
  268.         local total_resources = calculateResources(start_level, end_level)
  269.         displayTotalResources(start_level, end_level, total_resources)
  270.     else
  271.         term.setTextColor(colors.red)
  272.         print("Ungültige Eingaben. Bitte stelle sicher, dass beides Zahlen sind und das Startlevel kleiner als das Ziel-Level ist.")
  273.     end
  274.  
  275.  
  276.  
  277.  
  278.     function calc_color(color)
  279.         return math.pow(2, color - 1)
  280.     end
  281.  
  282.     function msg(gap, line, color, groundb, text)
  283.         term.setBackgroundColor(calc_color(groundb))
  284.         term.setCursorPos(gap,line)
  285.         term.setTextColor(calc_color(color))
  286.         text = term.write(text)
  287.     end
  288.  
  289.     --Programm neustarten                                                )
  290.     msg(01,17,01,06,"           -> neue Berechnung starten <-           ")
  291.     msg(01,19,01,15,"               -> System Neustart <-               ")
  292.  
  293.     local event, button, X, Y = os.pullEvent("mouse_click")
  294.     if X >= 01 and X <= 51 and Y == 17 then --neue Berechnung
  295.         -- neue berechnung
  296.     elseif X >= 01 and X <= 51 and Y == 19 then --restart
  297.         os.reboot()
  298.     end
  299.     sleep(0.5)
  300. end
  301.  
Advertisement
Add Comment
Please, Sign In to add comment