Custom events are a new feature of MundoSK. They work similarly to functions; you call them using
call custom event %string% [to] [det[ail]s %-objects%] [arg[ument]s %-objects%]
The key differences between custom events and functions is that calling a custom event isn't tied to a specific section of code. You don't need to have any Skript code that listens for custom events, and you could have multiple sections of code that listen to custom events, unlike functions, where you must have a function and that can be the only one. This allows for public scripts or even SkqAddons to add events that can be listened to in server-owner created scripts.
Custom events are extremely easy to use. You simply call the custom event with an id, such as "faction create", and optionally details and arguments.
Details are used in events as event-type. For example, if you had a detail 3426
, event-number
would equal 3426
. Details may be of any type that is in Skript by default (number, string, player, world, etc.) as well as of any type added in MundoSK (creator, achievement, difficulty, etc.). If you have two or more details of the same type, the detail that comes last wins. Ex. If you have details "String Detail", 357, mine_wood, 825
you can see you have two numbers, so event-number will equal 825, not 357.
Arguments are like details, except that you may have multiple arguments of the same type, and they can be of any type from any addon. Arguments are accessed from within the event using custom event's args (The expression is loopable)
For both details and arguments, you have to put them in a list variable and then call the custom event, otherwise you'll get an internal error. Ex.
call custom event "faction create" to details {_details::*} args {_args::*}
You can also access the id of the event using custom event's id.
The actual event syntax is:
[custom] (event|evt) [%-string%]
Let's look at an example where you have a command that lets a player create a faction, then calls the "faction create" event:
command /factioncreate: permission: faction.create usage: /factioncreate trigger: #Faction creation stuff set {_details::*} to player, string-arg call custom event "faction create" to details {_details::*} evt "faction create": broadcast "&2%event-player% created a new faction called %event-string%!"
Assuming event-player is the player and the event-string is the faction name
And that's really it. The event is called using the effect, and the triggers that listen to the custom events with that id, as well as the triggers that listen to all custom events are called and can use the details to complete actions.