Skip to content
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

Engine Wishlist #1

Open
LemmaEOF opened this issue May 9, 2019 · 29 comments
Open

Engine Wishlist #1

LemmaEOF opened this issue May 9, 2019 · 29 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@LemmaEOF
Copy link
Member

LemmaEOF commented May 9, 2019

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:

  • Lua (multiple options: LuaJ, LuaJIT, JNLua)
  • Python (Jython for 2.7, but I can't find anything for 3.x)
  • SCarpet (could potentially run on top of Python?)
  • Ruby (JRuby)

If anyone knows good JSR-223 compliant engines for any of these languages that are under permissive license, please send them here.

@LemmaEOF LemmaEOF added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels May 9, 2019
@Frontrider
Copy link
Member

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
Copy link
Member Author

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
Copy link

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

@Juuxel
Copy link
Member

Juuxel commented May 11, 2019

Is there a JSR-223 engine for ZS?

@LemmaEOF
Copy link
Member Author

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
Copy link

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

@Frontrider
Copy link
Member

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
Copy link
Member

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
Copy link
Member Author

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
Copy link
Member Author

LemmaEOF commented May 14, 2019

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
Copy link
Member Author

…wait, I might be able to jitpack it.

@Frontrider
Copy link
Member

It looks messy.

@LemmaEOF
Copy link
Member Author

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

@LemmaEOF
Copy link
Member Author

LemmaEOF commented May 14, 2019

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
Copy link
Member Author

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
Copy link
Member

Is it up on a branch?

@LemmaEOF
Copy link
Member Author

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
Copy link
Member Author

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.

@CottonMC CottonMC deleted a comment from Nathan22211 Oct 16, 2019
@Pannoniae
Copy link
Member

why

@CottonMC CottonMC deleted a comment from Nathan22211 Apr 14, 2020
@LemmaEOF
Copy link
Member Author

LemmaEOF commented May 2, 2020

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

  • scripting-cpython is not feasible to use, since it depends on the python installed on the host computer, and it's difficult passing objects between JVM and Python VM.
  • I made an attempt to make a mod wrapper for Kotlin JSR-223, but without any luck due to weird classpath issues.
  • I started working on a mod wrapper for Frege, but I need to put stuff onto maven local for it to work properly.
  • Groovy has a Compilable and Invocable script engine, and Juuz is thinking of making a mod wrapper for it.
  • LuaJ has a 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.

@Juuxel
Copy link
Member

Juuxel commented May 2, 2020

Frege? That's interesting.

@LemmaEOF
Copy link
Member Author

LemmaEOF commented May 2, 2020

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

@Frontrider
Copy link
Member

Frege would be an interesting one.

Fabric Kotlin should have the script engine already in there.

@Juuxel
Copy link
Member

Juuxel commented May 3, 2020

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
Copy link
Member Author

LemmaEOF commented May 3, 2020

@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
Copy link
Member

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

@Nathan22211
Copy link

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

@sylv256
Copy link
Collaborator

sylv256 commented Mar 17, 2021

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

I might work on something like this in the future.

@LemmaEOF
Copy link
Member Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants