Skip to content

Commit

Permalink
Fixed file loading while building
Browse files Browse the repository at this point in the history
  • Loading branch information
mandaw2014 committed Jul 20, 2022
1 parent fcc8fe7 commit 50fbc7d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions UrsinaAchievements/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
import os
from direct.stdpy import thread

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

_achievements_list = []
try:
with open(f"{_path}/achievements.json", "r", encoding="utf-8") as save_file:
with open(achievements_json, "r") as save_file:
_achievements_got = json.load(save_file)["achievements_got_names"].copy()
except FileNotFoundError:
with open(f"{_path}/achievements.json", "w", encoding="utf-8") as save_file:
with open(achievements_json, "w") as save_file:
_achievements_got = []
json.dump({"achievements_got_names": []}, save_file, indent=4)

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


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


Expand Down
2 changes: 1 addition & 1 deletion car.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def __init__(self, position = (0, 0, 4), rotation = (0, 0, 0), topspeed = 30, ac
self.camera_shake_option = True

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

try:
Expand Down

0 comments on commit 50fbc7d

Please sign in to comment.