Jump to content

Oh dear,


Rawrstin

Recommended Posts

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
Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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
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...