-
-
Notifications
You must be signed in to change notification settings - Fork 372
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
Script type & expression. #6702
base: feature/script-reflection
Are you sure you want to change the base?
Script type & expression. #6702
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quick first impressions
609bac0
to
064f1ce
Compare
Co-authored-by: Patrick Miller <apickledwalrus@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. One major thing lots of switches can be replaced with switch expressions now that they are available. Additionally, do you think it is worth having an expression like path of %scripts%
or should we just keep it to the toString? I'm not sure how far we want to go in terms of file-type syntax.
I think I kept the toString as the path because we have |
Co-authored-by: Patrick Miller <apickledwalrus@gmail.com>
Description
The first step towards supporting proper reflection & introspection: a type and object handles for scripts.
This adds:
script
type.Script
objects for disabled/unlinked scripts.[script] reflection
for most linked features & breaking changes.Validated
interface to be used by scripts and other resources that could become obsolete. This is purely a testing API right now.[the] [current] script
,[the] script[s] [named] %strings%
.name
property of scripts.name of script
did, e.g.scripts/folder/MyScript.sk
->folder/MyScript
.scripts/folder/MyScript.sk
->MyScript
.Script
dummy object for disabled scripts.enable skript "hello.sk"
skript
andscript
to be unhelpful and confusing, people might mistakereload skript ...
to mean reloading Skript, when it was actually for files.skript file ...
, orscript...
to make that clearer.Breaking Changes
The
enable|disable skript %string%
pattern variation was removed. You can still useskript file
orscript
.Resource safety has been significantly improved: there were basically zero checks on what you tried to reload/disable previously. If it wasn't a valid file it would throw huge exceptions, and if it was it would just get processed without any kind of safety checks.
scripts/
directory (unless you're running in Test mode!)With the experiment enabled, unloading is now considered different from disabling in syntax: disabling a script will unload it and prepend
-
to its file name. Unloading it will just unload it from memory (but not disable it, so it would load normally upon next restart).Where Next?
This could be the start of some reflection.
I'd like to see a bit of introspection in the future (maybe looking at what structures are in a script, some features from Config, etc.)
There was some discussion about some other reflective stuff (like dynamic function calls) which would probably tie into this quite nicely. I've opened a branch for anybody who wants it.
This could move in the direction of runtime-parsed scripts, anonymous scripts, etc.
I'm also wondering about abstracting some kind of loadable interface (or maybe just use Config) so that we can permit the [re]loading of other Skript-related things that can be loaded (aliases, config, etc.)
I don't have any plans for the loading of non-script-provided files (e.g. a user-provided config
.sk
file) at this point, but if I abstracted this back a layer then it would be really easy (for an addon) to provide that in the future if somebody wants to.Target Minecraft Versions: any
Requirements: none
Related Issues: none