Open LemmaEOF opened 5 years ago
As discussed on discord, kotlin can be a good addition, as it's one of the few statically typed scripting languages. Loading languages as addons could also be an option. If we know which ones are the ones that are actually used, than we can package those as defaults.
I was primarily thinking the addons route since we can just nest addons once we're happy with them and give folks an option to only pack the addons they want.
What I think would be easiest to implement is ZenScript. It is open-source, and was made for minecraft scripting.
Is there a JSR-223 engine for ZS?
No, there isn't. The problem with ZenScript is that it is very focused in on Minecrafting scripting and especially recipe tweaking, and so there's not really a general interpreter to run code that isn't related to Minecraft. It's not JSR-223 compliant, so it can't really be added.
Not sure. It might not be too hard if it wasn't JSR-223.
The system is designed to work with java script engines. Not being compliant, means that you can not reuse the same compat layers that we can use for every other language, and you have to re-implement every single thing ever added specifically for it, instead of working out of the box.
Zenscript did came up in my head as a good option for familiarity, but...
For zenscript's functionality, you'd implement your api once in java, (code that works from java as well), than it works from javascript, kotlin, lua, python etc...
Ultimately, it would likely require writing a new ZenScript interpreter from scratch that’s redesigned fundamentally to be a more abstract scripting language, and I don’t currently have time for that. I’d rather focus on making support for languages that already have compliant interpreters.
scripting-cpython seems like it might work for a python scripting lib, but I don't know Maven and so I can't get it to compile. If someone could help get me a jar of it so I could shadow it, that'd be aces.
…wait, I might be able to jitpack it.
It looks messy.
Yeah, it honestly does, but it's the only JSR223 python 3.x I can find.
in fact, the only other JSR223 python I can find period is by the same group and it looks to be set up in nearly exactly the same way. edit: taking a more thorough look it looks a bit less messy, but I really wanna have python 3.x support instead of 2.7 so I don't know what to do
Alright: new problem with the python JSR223 stuff is that it's made with maven, not Gradle. This is an issue because it means that I can't use shadow for them, which basically defeats the entire point. I'm not sure what to do. I'll ask some others if they have any ideas.
Is it up on a branch?
I've almost got it ready! It turns out Loom/Loader will let you JiJ any jar, not just a Fabric mod. That means I can just include
the jar from maven and it'll be fine!
https://github.com/CottonMC/cotton-scripting-py2/releases/tag/1.0.0 Jython version is now available. I'm gonna keep hunting and see if scripting-cpython is feasible to use for python 3.
why
A few updates, since it's been a while:
Compilable
and Invocable
script engine, and Juuz is thinking of making a mod wrapper for it.Compilable
script engine but not an Invocable
one, which means that it can't 100% be used. I might try PR'ing in Invocable
support someday.Frege? That's interesting.
Frege has a Compilable
but not Invocable
script engine. That should theoretically be fixable too.
Frege would be an interesting one.
Fabric Kotlin should have the script engine already in there.
Groovy has a
Compilable
andInvocable
script engine, and Juuz is thinking of making a mod wrapper for it.
That wrapper is now done: https://github.com/CottonMC/CottonScripting-Groovy
@Frontrider Fabric Kotlin should absolutely not have the script engine already in here, because it would triple the size of the mod (because it'd need the entire kotlin compiler) and only LibCD and Cotton Scripting would use it.
That was forgelin, yeah. This one does something else.
now i'm beginning to miss this just looking at it
now i'm beginning to miss this just looking at it
I might work on something like this in the future.
I mean feel free to PR to this if you wanna extend it, I got myself burnt out on minecraft modding again (and I also wanted to try and make Chase which probably wouldn't work with Parchment at all oops)
With stock Cotton Scripting, you can only really use JavaScript for scripting, and even then Nashorn is being deprecated. I want to see if we can get some JSR-223 engine addons to let people run other scripting languages. The primary ones we should get support for are:
If anyone knows good JSR-223 compliant engines for any of these languages that are under permissive license, please send them here.