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
Check if the callback can be called.
  • Loading branch information
CookStar committed Oct 4, 2021
commit 96145c7d65ce1f48a6ff94188024ab7c32744685
4 changes: 4 additions & 0 deletions addons/source-python/packages/source-python/cvars/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def __init__(self, *convars):

def __call__(self, callback):
"""Store the callback and add it to convars."""
# Is the callback callable?
if not callable(callback):
raise ValueError('Given callback is not callable.')

# Store the callback
self.callback = callback

Expand Down