Skip to content

Added 'event_name' to event's kwargs #76

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

Merged
merged 1 commit into from
Oct 28, 2015
Merged

Added 'event_name' to event's kwargs #76

merged 1 commit into from
Oct 28, 2015

Conversation

Mahi
Copy link
Contributor

@Mahi Mahi commented Oct 28, 2015

Event's name is still required when registering the same callback for multiple events:

@Event('player_spawn', 'player_jump')
def on_event(**eargs):
    print('Player with userid of {userid} triggered {event_name}.'.format(**eargs))

I chose to use 'event_name' since it can still be grabbed in the parameters ('event name' could not be):

@Event('player_spawn')
def on_spawn(event_name, **eargs):
    pass

And simply using 'name' felt a little ambiguous.

@Mahi
Copy link
Contributor Author

Mahi commented Oct 28, 2015

GameEvent objects also have is_local() and is_reliable() which are both ignored by KeyValues, but I left them out as I wasn't sure if they're relevant enough to be added to the dict.

satoon101 added a commit that referenced this pull request Oct 28, 2015
Added 'event_name' to event's kwargs
@satoon101 satoon101 merged commit facb497 into Source-Python-Dev-Team:event_test Oct 28, 2015
@satoon101
Copy link
Member

Good point. Thank you. I'm not sure about the other two, as well.

We "could" also pass the GameEvent object itself as a kwarg, which would fix the issue I noticed last night where we cannot directly duplicate the event anymore. Not sure how widely used that would be, though.

@Mahi
Copy link
Contributor Author

Mahi commented Oct 28, 2015

I also thought about passing the GameEvent object as a kwarg, but I found very little (if any) use to it. What exactly do you mean by "directly duplicate the event"?

@Mahi Mahi deleted the event_test branch October 28, 2015 13:27
@satoon101
Copy link
Member

events.manager.game_event_manager has a method to duplicate an event. It requires the GameEvent object to be passed.
https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/src/core/modules/events/events_wrap.cpp#L244

It was mentioned in this thread of your's previously:
http://forums.sourcepython.com/showthread.php?727

However, as I said, I'm not sure how widely used it would even be. Creating a custom event instead, and passing in the kwargs would be just as good an option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants