-
-
Notifications
You must be signed in to change notification settings - Fork 368
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
Add an event called when a function is executed #2944
Comments
where would this be useful? |
The suggestion may sound odd, but let's imagine a mini-game script. What I was looking for and I didn't find, is a way to add functionality without modifying the main script, so an event which would be called when the main script functions are executed would allow this. Useful for doing some kind of add-on but in Skript. Of course, my suggestion does not apply if something like this already exists. |
It's possible to overwrite functions by having your script be parsed after the first script. However, I'm unsure if this is intended behaviour or just a bug that I'm abusing. |
Very interesting, it seems indeed to be a good way which I had not thought of, thank you very much! I'll take a look at it. Unfortunately it does not seem to work since a function has already been loaded and it cannot load a second one with the same name. |
so more generally what you're looking for is a way to create custom events? |
I don't know if we can call it custom events, but just a way to detect that something has been executed in another code, so I thought of an event that detects when a function is called. I edited the example of my first comment. |
I'm not 100% sure how I feel about this. Ill mark it with low priority and leave it open for discussion. |
Personally, I find this feature redundant... You can technically already do this. In my scripts when I want to trigger a "custom" event, I just use functions. For example:
Where |
Hello, thank you for your response. I don't think I explained my suggestion properly. game.sk: function game_example():
game_start()
# </> ...
function game_start():
send "The game has been started!" to {game::players::*}
# </> ... modifier.sk: on function:
event-function is "game_start"
# </> other code that would allow to add other effects to the main script Of course, this is a suggestion for a very specific use. 😅 |
Just like #4360, I think this feature would be fine as a Bukkit event if addons may need this but not as a Skript event. I don't think we should create a Skript event for this since most functions don't need event calls, and for those few that do it could be coded into the event as mentioned above (custom events are suggested in #121). Bukkit event are actually already called for functions if an addon requests it (see #816 and 0ccbcd8) (if you want to use it with skript-reflect you can use the instance from |
Description
Hello!
I want to know if it is technically possible to add an event that would be called when a function of a script is executed.
Since I don't know if my English is correct, here is an example of what I mean by that:
main.sk
test.sk
This would be extremely handy for adding scripts based on others, for example adding functionality to the base script.
If you think this is not possible or if you have any questions or an alternative to this, please let me know. As usual, thank you very much for your work on Skript. Thanks for reading, have a nice day!
The text was updated successfully, but these errors were encountered: