Git Product home page Git Product logo

Comments (5)

michaelzangl avatar michaelzangl commented on August 30, 2024

I added a method to access old chat messages.

Have a look at the example. Is this what you wanted?

There is also an example that stops when a given command was written (stopOnChatMessage).

from minebot.

TheTechPony avatar TheTechPony commented on August 30, 2024

Yes, this will work very well. And do you have any extra documentation in scripting you can link me to? I'm new to Java and this is what's introducing me to the language. I just need a list of functions Minebot uses and possibly some example of them in a script.

from minebot.

TheTechPony avatar TheTechPony commented on August 30, 2024

https://gyazo.com/9db76d4bf2192a23ca3e4a6f71c58f4b.png I get this error with this code copied off the documentation

minescript.doStrategy(minescript.stack(
stopOnChatMessage(),
minescript.strategy("minebot", "mine", "dirt")));

function stopOnChatMessage() {
// This should work with the essentials /msg command
// This matches messages sent from myUserName containing stop.
// You can replace \u00a7 with ยง but make sure to change the encoding to UTF-8 in
// your text editor (should only be a problem for windows users)
var re = /^\u00a76[\u00a7c(myUserName)\u00a76 -> \u00a7c(me)\u00a76] \u00a7r.stop.$/;

// Alternatives to this regexp:
//   Match server shutting down:
//      /^\u00a76.*shut.*down/
//              ^ Replace this with the color code your server uses.
//   Stop as soon as that person is mentioned (join message, ...)
//      /supUserName/
//   Stop as soon as the word test is in the message:
//      /\btest\b/


// we ignore old messages
var messageCount = minescript.getChatMessages().length;
// we should not just return false once, so we need to store the status.
var stopReceived = false;
return generateStopStrategy(function(h) {
        var messages = minescript.getChatMessages();
        // this goes through all new messages
        for (; messageCount < messages.length; messageCount++) {
            stopReceived |= re.test(messages[messageCount].textFormatted + "");
        }
        return stopReceived;
    }, false, "Stop when moving down.");

}

from minebot.

michaelzangl avatar michaelzangl commented on August 30, 2024

You also need to copy the generateStopStrategy function a few lines above that example.

from minebot.

TheTechPony avatar TheTechPony commented on August 30, 2024

Oh yeah I see, thanks a lot! :)

from minebot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.