Jump to content

Oh dear,


Recommended Posts

Posted (edited)

Hey again y'all,

 

Update: would this work properly?

public void onMessage(String message) throws InterruptedException {
     if (message.contains("Oh dear,")) {
          dead = true;
     }
}

I'm still new to understanding the API easily, so sorry for the beginner question.. sad.png

 

Thanks in advance!

Edited by Rawrstin
Posted

You use a message listener, look for a game message with that text and then write the code in the onMessage() method. :) 
http://osbot.org/api/org/osbot/rs07/listener/MessageListener.html
http://osbot.org/api/org/osbot/rs07/api/ui/Message.MessageType.html
http://osbot.org/api/org/osbot/rs07/api/ui/Message.html
Those should help out enough.

I've always been a fan of people figuring things out for themselves, but if you require more help be sure to reply :)

Posted (edited)

Hey again y'all,

 

Quick question in regards to detecting the chatbox spitting back the game message displayed on death..

 

Ex:

*I DIED*

game says "Oh dear, you are dead!"

*I CRY*

 

I'm still new to understanding the API easily, so sorry for the beginner question.. sad.png

 

Thanks in advance!

Oh.. nvm , you'll be wanting to use onMesage.. There is some snippets lying around the forums

Edited by Qubit
Posted

Hey again y'all,

 

Update: would this work properly?

public void onMessage(String message) throws InterruptedException {
     if (message.contains("Oh dear,")) {
          dead = true;
     }
}

I'm still new to understanding the API easily, so sorry for the beginner question.. sad.png

 

Thanks in advance!

 

I have updated the OP Post code.. I think that should work.. testing now! (Could still use help, lol)

Posted (edited)

I have updated the OP Post code.. I think that should work.. testing now! (Could still use help, lol)

 

The onMessage method takes a Message argument, not String

 

Example:

public void onMessage(Message msg) throws InterruptedException {
     if (msg.getType() == MessageType.GAME && msg.getMessage().contains("Oh dear,")) {
          dead = true;
     }
}

 

Edited by FrostBug
  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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