Feature: Limited functions #7715
Replies: 3 comments 1 reply
-
what does everyone think about
the functions must be local to be "usable" |
Beta Was this translation helpful? Give feedback.
-
you guys can call those modules. you can create a script called module_script.sk for example, and other scripts can make use of its functions. |
Beta Was this translation helpful? Give feedback.
-
I would want to be proceed very cautiously and thoughtfully if we were interested in adding any sort of package-like or import-like functionality. Due to the nature of this being more of a language proposal, I am going to convert this issue into a discussion which is more suited for that sort of conversation. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Suggestion
I know it may sound confusing at first, but it's a very interesting idea.
Limited functions are functions that can only be used inside of Skript files within a specific folder inside of the scripts folder. Say you're making multiple games in the same server but you're too lazy to go and prefix every global function. Instead, you can assign the functions to the directory for the specific game you're making, and then they'll only be usable within that folder, allowing for functions from other folders to share the same name but do their own thing.
The way you can assign a function to a directory could be the following:
function name(parameters: types) [:: return type] [in "directory_name"]:
, where "directory_name" is the name of the folder inside of the scripts folder, and you can go further by doing, for example, this:directory_name/directory2_name/directory3_name
, assuming directory3_name is inside of directory2_name which is inside of directory_name.The name "Limited Functions" is just a quick (although 2nd because I edited the initial one) name that I gave to this feature and could be replaced with something better.
I want this to be a quick suggestion and I trust you understand what I'm suggesting for Skript. Let us now move to the Why? category.
Why?
This is a perfect alternative to prefixing your global functions (example:
function horrorGame_jumpscare()
), which makes the code more understandable and it also makes it easier to call the functions. It essentially allows for better communication between Skript files within the same directory, and this is very useful for making some pretty complicated things. You can't always put everything into the same Skript file because reloading becomes a bigger pain as you code in it.Other
This may or may not be the most interesting suggestion I've given so far. I hope to see it in the next Skript feature release, 2.11, which, according to the release model, will be released next month on the 15th. If not, then perhaps July 15th, which is exactly 10 days after my birthday.
Agreement
Beta Was this translation helpful? Give feedback.
All reactions