Zergatul / cheatutils

MIT License
33 stars 11 forks source link

[Feature Request] Script to read chat #72

Closed nayfaan closed 1 month ago

nayfaan commented 3 months ago

Is it possible to have a function that gets the last (few) line our chat box / command feedbacks?

...and is there a sleep/wait function to insert pauses into a script?

Zergatul commented 3 months ago

You can't normally sleep from script, because it is getting executed in the main thread. Sleep with just cause hanging. You can use this:

delayed.run(10, () => {
    // your code
    // it will be executed after 10 ticks passed
});

As for chat, I can add this. Maybe it will be better to have dedicated event for Events Scripting module:

events.onChatMessage(() => {
    string message = chat.getCurrentMessage();
    // ...
});

But there is not much string methods you can use, so probably you will not be able to do some sort of string parsing. What you are trying to achieve?

nayfaan commented 3 months ago

I have a command that does things and gives a feedback in chat when it's done processing. I would like the script to wait for that feedback line before sending the next command to main

Zergatul commented 3 months ago

Ok, then events should be the best place for it. Are you using 1.20.4 version?

nayfaan commented 3 months ago

yes, that sounds like what I need. And yes I'm using the latest version on 1.20.4. Thank you!

imnewtocodeplshelp commented 2 months ago

hello i am trying to make a code that will wait a few seconds before runing so i tried the first code and it dident work like my name sugests i am new to code so pls do you know what im doing wrong and yes i know i have spelling mistakes

Zergatul commented 2 months ago

hello i am trying to make a code that will wait a few seconds before runing so i tried the first code and it dident work like my name sugests i am new to code so pls do you know what im doing wrong and yes i know i have spelling mistakes

Join matrix server and show your code

imnewtocodeplshelp commented 2 months ago

sorry but i dont have a clue what is matrix like i said im new to this

Zergatul commented 1 month ago

Ability to process chat messages added in 2.13.2 version