Jump to content

In game message listener trouble


killsmh

Recommended Posts

getBot().addMessageListener(f2pWc.this); 

@Override
    public void onMessage(Message message) {
        if (message.getType() == Message.MessageType.GAME && message.getMessage().contains("It's ready to add to the sapling.")) {
                 sapling.interact("Add-mulch");
        }
    }

It doesn't seem to be working.. :c

My bad everything seems to be a-okay! 

Edited by killsmh
Link to comment
Share on other sites

42 minutes ago, killsmh said:

getBot().addMessageListener(f2pWc.this); 

@Override
    public void onMessage(Message message) {
        if (message.getType() == Message.MessageType.GAME && message.getMessage().contains("It's ready to add to the sapling.")) {
                 sapling.interact("Add-mulch");
        }
    }

It doesn't seem to be working.. :c


No need to do addMessageListener if it's you main class extending from Script :) 

Just add some debug logs to check what codes gets executed and which not.
I'm not sure where the sapling variable is coming from, I asusme you set it in the onLoop? Just load the sapling ad hoc

BUT those are bad habbits, do this instead:
Never use any interaction code in the messageListener, only in the onLoop thread.
You can set a boolean in the onMessage and check that boolean in the onLoop to execute your code and reste the boolean after that :)

Edited by Khaleesi
  • Heart 1
Link to comment
Share on other sites

On 7/13/2023 at 11:21 PM, Khaleesi said:


No need to do addMessageListener if it's you main class extending from Script :) 

Just add some debug logs to check what codes gets executed and which not.
I'm not sure where the sapling variable is coming from, I asusme you set it in the onLoop? Just load the sapling ad hoc

BUT those are bad habbits, do this instead:
Never use any interaction code in the messageListener, only in the onLoop thread.
You can set a boolean in the onMessage and check that boolean in the onLoop to execute your code and reste the boolean after that :)

Thank you for helping everyone!

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...