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