Skip to content

Commit 50fbc7d

Browse files
committed
Fixed file loading while building
1 parent fcc8fe7 commit 50fbc7d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

UrsinaAchievements/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
import os
99
from direct.stdpy import thread
1010

11-
_path = os.path.dirname(os.path.abspath(__file__))
11+
_path = os.path.dirname(sys.argv[0])
12+
achievements_json = os.path.join(_path, "./UrsinaAchievements/achievements.json")
1213

1314
_achievements_list = []
1415
try:
15-
with open(f"{_path}/achievements.json", "r", encoding="utf-8") as save_file:
16+
with open(achievements_json, "r") as save_file:
1617
_achievements_got = json.load(save_file)["achievements_got_names"].copy()
1718
except FileNotFoundError:
18-
with open(f"{_path}/achievements.json", "w", encoding="utf-8") as save_file:
19+
with open(achievements_json, "w") as save_file:
1920
_achievements_got = []
2021
json.dump({"achievements_got_names": []}, save_file, indent=4)
2122

@@ -37,7 +38,7 @@ def create_achievement(name:str, unlock_condition, icon:str=None, ringtone:str="
3738

3839

3940
def _save_achievements():
40-
with open(f"{_path}/achievements.json", "w", encoding="utf-8") as save_file:
41+
with open(achievements_json, "w") as save_file:
4142
json.dump({"achievements_got_names": _achievements_got.copy()}, save_file, indent=2)
4243

4344

car.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def __init__(self, position = (0, 0, 4), rotation = (0, 0, 0), topspeed = 30, ac
121121
self.camera_shake_option = True
122122

123123
# Get highscore from json file
124-
path = os.path.dirname(os.path.abspath(__file__))
124+
path = os.path.dirname(sys.argv[0])
125125
self.highscore_path = os.path.join(path, "./highscore/highscore.json")
126126

127127
try:

0 commit comments

Comments
 (0)