Skip to content

Commit 3832b71

Browse files
Update main_script.py in mrmine
1 parent 40010a7 commit 3832b71

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

v1.0/mrmine/main_script.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,33 @@ def tick():
2828
elif key in ["k", "q", "c", "s", "h", "u", " ", "p", "r"]:
2929
update_GUI_func(key)
3030

31+
def read_save_file_to_dict():
32+
save_data = {}
33+
with open('mrmine_save.txt', 'r') as file:
34+
for line in file:
35+
line = line.strip()
36+
if '=' in line: # Ensuring there's a key-value split
37+
key, value = line.split('=', 1) # Split on first '=' to handle complex values
38+
try:
39+
# Attempt to evaluate the value for correct data types
40+
save_data[key] = eval(value)
41+
except:
42+
# If eval fails, it's likely a string or ambiguous format
43+
save_data[key] = value
44+
return save_data
45+
3146
def mrmine_start_game():
3247
os.system('clear')
3348
update_GUI()
3449
try:
35-
36-
50+
read_save_file_to_dict()
51+
except Exception:
52+
print("Error while loading save file.")
3753
try:
3854
listener_thread = Thread(target=keypress_listener)
3955
listener_thread.daemon = True
4056
listener_thread.start()
41-
4257
while True:
4358
tick()
44-
4559
except KeyboardInterrupt:
4660
print("Game interrupted, exiting...")

0 commit comments

Comments
 (0)