It clears things up... technically, Python doesn't "know" that there are any events. In fact, if you click something on the screen, an event is created and an event handler is called. The PC doesn't even know that there is an event going on, it will never, it just goes on to compute "until it dies" lol.
having that said, I'd say that explicitly importing the module makes it clear what the script is for. EventScripts, as I understood it, looks for all functions in the python file and if it finds a function name which matches an event name, like player_death, goes on to call this function with the proper arguments (userid and so on).
SP, again, as I understand it, 'registers' functions as events using the Event decorator. The function names have to be the same as the event name (I guess), but SP doesn't have to look for those in the python file, it just 'gets' them.
Imagine someone looking at some code and trying to figure out what it is (doesn't have any experience of SP or EventScripts, just pure Python).
Here, this guy can be 100% sure that player_death is an Event, because you explicitly declare it that way:
Syntax: Select all
from events import Event
@Event
def player_death(game_event):
pass
Here, he/she doesn't (at least not 100%)
Syntax: Select all
import es
def player_death(event_var):
pass
Sure you can comment things, but why all those comments if the API does half the commenting for you while providing more flexible ways of doing things?
velocity wrote:In this case, why wouldn't I use sourcemod instead?
Any reason for that?
Yep, Python! :D