superblaubeere27 / ClientBase

MIT License
115 stars 18 forks source link

How to use the script system? #3

Closed liaic closed 2 years ago

liaic commented 4 years ago

seems like it's different from liquidbounce?

superblaubeere27 commented 4 years ago

Yes. I have no documentation on it, because it is meant to be modified by the coder. If you want to edit it: https://github.com/superblaubeere27/ClientBase/blob/master/src/main/java/net/superblaubeere27/clientbase/scripting/ScriptManager.java And itt uses the Nashorn Engine (https://en.wikipedia.org/wiki/Nashorn_(JavaScript_engine)). If you want to know how to use it just google it :D

Liux71 commented 2 years ago

Do you have like a basic script to test if it works?

superblaubeere27 commented 2 years ago

Do you have like a basic script to test if it works?

I reconstructed how a script should look like, but I am not sure if it works:

First of all, every file related to the script has to be in a zip file.

The most important file is the (manifest.json).

{
    "name": "Test",
    "description": "Test script",
    "modules": [
        {
            "name": "TestModule",
            "description": "Script engine test",
            "category": "FUN",
            "script": "test_module.js"
        }
    ]
}

Each module has it's own javascript file in the zip file (test_module.js):

function onMotionUpdate(event) {
    if (event.getEventType().name() != 'POST') {
        return;
    }

    const player = rt.getMinecraft().getThePlayer();

    if (event.isOnGround()) {
        event.setPitch(-90);
    }
}
Liux71 commented 2 years ago

Ok thanks