Skip to content

Added the ability to add callbacks to ConVar that will be called when ConVar is changed. #421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Revert "Changed to check if ConVar is a valid ConVar."
This reverts commit 94e24ba.
  • Loading branch information
CookStar committed Oct 4, 2021
commit 6fea4b507e9f71e95e2e0837d7737f90a21874be
15 changes: 7 additions & 8 deletions addons/source-python/packages/source-python/cvars/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,15 @@ def __init__(self, *convars):

_convars = []
for convar in convars:
if isinstance(convar, str):
convar_name = convar
elif isinstance(convar, ConVar):
convar_name = convar.name
else:
if not isinstance(convar, (str, ConVar)):
raise ValueError('Given convar is not ConVar or ConVar name.')

convar = cvar.find_var(convar_name)
if convar is None:
raise ValueError(f'"{convar_name}" is not a valid ConVar.')
elif isinstance(convar, str):
convar_name = convar
convar = cvar.find_var(convar_name)
if convar is None:
raise ValueError(
f'"{convar_name}" is not a valid ConVar name.')

_convars.append(convar)

Expand Down