Scarpet question: What types of expressions for (player) in __on_player_<event>(player) are supported?
TheGreatCatAdorer opened this issue ยท 3 comments
Fabric-Carpet 1.4.38. I would like to trigger __on_player_connects() in a function for any player. Is there any way to do this or do I have to run the command at an interval?
Not sure if I understood it fully, so giving a few options:
If you are looking for the list of built-in events, you have them here (here for player events specifically).
If what you want is to "fake" trigger those events from a piece of your code for every app (since in a player-scoped app every player is independent), you can use signal_event
. Note that this will trigger the event for any app, not only instances of your app, you can also use custom events if you wish, see handle_event
right above.
If you are trying to call the function in the given app's instance, just call it like any other defined function: It actually is.
If you want to spawn a fake player from an app, you can do so by using the run()
function which will run the command it's passed to it.
Last but not least, if you want to run something every so often, you can use the schedule()
function and schedule it again at the end of the function you've scheduled.
If I still didn't get what you mean (which is definitely possible), I'll try to help you if you give me more details about what you're looking for.
events handles are just functions. You can just call them. If you want to call these for every player directly in the script you would use for(players('all'), __on_player_connects(_))
, or if dimension is important for(players('all'), in_dimension(_, __on_player_connects(_)))
- still executing in your context (for global apps its all what you would need).
For player based apps (one app instance per player), you would probably want to signal
, guessing something like for(player('all'), signal('player_connects', _, _))
(note duplicated player arguments, one for targetting specific player app instance and second for passing a standard player argument - self. This way they will execute in each players' app contexts.