CottonMC / CottonScripting

JSR-223 scripting in data packs!
MIT License
3 stars 1 forks source link

Engine Wishlist #1

Open LemmaEOF opened 5 years ago

LemmaEOF commented 5 years ago

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.

Frontrider commented 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.

LemmaEOF commented 5 years ago

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.

Dolphin2Point1 commented 5 years ago

What I think would be easiest to implement is ZenScript. It is open-source, and was made for minecraft scripting.

Juuxel commented 5 years ago

Is there a JSR-223 engine for ZS?

LemmaEOF commented 5 years ago

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.

Dolphin2Point1 commented 5 years ago

Not sure. It might not be too hard if it wasn't JSR-223.

Frontrider commented 5 years ago

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...

Frontrider commented 5 years ago

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...

LemmaEOF commented 5 years ago

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.

LemmaEOF commented 5 years ago

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.

LemmaEOF commented 5 years ago

…wait, I might be able to jitpack it.

Frontrider commented 5 years ago

It looks messy.

LemmaEOF commented 5 years ago

Yeah, it honestly does, but it's the only JSR223 python 3.x I can find.

LemmaEOF commented 5 years ago

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

LemmaEOF commented 5 years ago

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.

Frontrider commented 5 years ago

Is it up on a branch?

LemmaEOF commented 5 years ago

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!

LemmaEOF commented 5 years ago

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.

Pannoniae commented 5 years ago

why

LemmaEOF commented 4 years ago

A few updates, since it's been a while:

Juuxel commented 4 years ago

Frege? That's interesting.

LemmaEOF commented 4 years ago

Frege has a Compilable but not Invocable script engine. That should theoretically be fixable too.

Frontrider commented 4 years ago

Frege would be an interesting one.

Fabric Kotlin should have the script engine already in there.

Juuxel commented 4 years ago

Groovy has a Compilable and Invocable script engine, and Juuz is thinking of making a mod wrapper for it.

That wrapper is now done: https://github.com/CottonMC/CottonScripting-Groovy

LemmaEOF commented 4 years ago

@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.

Frontrider commented 4 years ago

That was forgelin, yeah. This one does something else.

Nathan22211 commented 3 years ago

now i'm beginning to miss this just looking at it

sylv256 commented 3 years ago

now i'm beginning to miss this just looking at it

I might work on something like this in the future.

LemmaEOF commented 3 years ago

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)