fixed context errors in votingmachine and reordered installation cmds (#110)

This commit is contained in:
Fang 2025-02-23 11:30:06 +05:30 committed by GitHub
parent c0722a6916
commit e5b46f29c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 7 deletions

View file

@ -58,7 +58,7 @@ def vote(pb_id, client_id, vote_type):
else:
activity = bs.get_foreground_host_activity()
if activity is not None:
with _babase.Context(activity):
with activity.context:
bs.broadcastmessage(
f"{max_votes_required(len(active_players)) - len(voters)} votes required for {vote_type}",
image={"texture": bs.gettexture(
@ -75,7 +75,8 @@ def vote(pb_id, client_id, vote_type):
vote_machine[vote_type]["voters"] = []
if vote_type == "end":
try:
with _babase.Context(bs.get_foreground_host_activity()):
activity = bs.get_foreground_host_activity()
with activity.context:
bs.get_foreground_host_activity().end_game()
except:
pass
@ -120,7 +121,8 @@ def update_vote_text(votes_needed):
activity.end_vote_text.node.text = "{} more votes to end this map\ntype 'end' to vote".format(
votes_needed)
except:
with _babase.Context(bs.get_foreground_host_activity()):
activity = bs.get_foreground_host_activity()
with activity.context:
node = bs.NodeActor(bs.newnode('text',
attrs={
'v_attach': 'top',
@ -142,4 +144,4 @@ def remove_vote_text():
activity = bs.get_foreground_host_activity()
if hasattr(activity,
"end_vote_text") and activity.end_vote_text.node.exists():
activity.end_vote_text.node.delete()
activity.end_vote_text.node.delete()