forked from SilverStudioGames/WTS
Bug fix
* Fixed naughty list username retrieval failing on Windows
This commit is contained in:
parent
2956afe75a
commit
b38147852a
@ -17,19 +17,31 @@ default naughty_list_commentary = False
|
|||||||
label naughty_list:
|
label naughty_list:
|
||||||
|
|
||||||
python:
|
python:
|
||||||
|
# This code retrieves user name and displays it on a leaderboard-like
|
||||||
|
# list for funsies, the variable is discarded afterwards.
|
||||||
_username = None
|
_username = None
|
||||||
_d = [(i, get_character_progression(i)) for i in CHARACTERS if get_character_unlock(i)]
|
_d = [(i, get_character_progression(i)) for i in CHARACTERS if get_character_unlock(i)]
|
||||||
_d.append(["Snape", sna_friendship])
|
_d.append(["Snape", sna_friendship])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_username = os.getlogin().split(" ")[0].capitalize()
|
_username = os.getenv("USERNAME")
|
||||||
|
|
||||||
|
if not _username:
|
||||||
|
_username = os.getlogin()
|
||||||
|
|
||||||
|
# Windows returns an empty string when it encounters an error,
|
||||||
|
# in ucrtbase.dll, and we need to catch that.
|
||||||
|
if not _username:
|
||||||
|
raise Exception("Cannot retrieve user name, using the fallback.")
|
||||||
|
|
||||||
|
_username = _username.split(" ")[0].capitalize()
|
||||||
_d.append([_username, 999])
|
_d.append([_username, 999])
|
||||||
|
|
||||||
except:
|
except:
|
||||||
_d.append(["Genie", 999])
|
_d.append(["Genie", 999])
|
||||||
|
|
||||||
_d.sort(key=lambda x: x[1], reverse=True)
|
_d.sort(key=lambda x: x[1], reverse=True)
|
||||||
|
|
||||||
|
|
||||||
show screen naughty_list(_d)
|
show screen naughty_list(_d)
|
||||||
with d3
|
with d3
|
||||||
|
|
||||||
@ -38,16 +50,19 @@ label naughty_list:
|
|||||||
|
|
||||||
pause 1.0
|
pause 1.0
|
||||||
|
|
||||||
if _username:
|
if _username is None:
|
||||||
gen "List checks out... But who the fuck is [_username]?" ("base", xpos="far_left", ypos="head")
|
|
||||||
else:
|
|
||||||
gen "I'm on the first place, nice!" ("base", xpos="far_left", ypos="head")
|
gen "I'm on the first place, nice!" ("base", xpos="far_left", ypos="head")
|
||||||
|
else:
|
||||||
|
gen "List checks out... But who the fuck is [_username]?" ("base", xpos="far_left", ypos="head")
|
||||||
|
|
||||||
call ctc
|
call ctc
|
||||||
|
|
||||||
hide screen naughty_list
|
hide screen naughty_list
|
||||||
with d3
|
with d3
|
||||||
|
|
||||||
|
python:
|
||||||
|
del _username
|
||||||
|
|
||||||
jump main_room_menu
|
jump main_room_menu
|
||||||
|
|
||||||
screen naughty_list(d):
|
screen naughty_list(d):
|
||||||
|
Loading…
Reference in New Issue
Block a user