Vogelbekdier 1 Posted May 11, 2021 Simple question; Trying to make a fire making script that will relight the new log once chat contains the message "The fire catches and the logs begin to burn" however I can't figure out how to grab the text from my chatbox.
Bonfire 334 Posted May 11, 2021 1 hour ago, Vogelbekdier said: Simple question; Trying to make a fire making script that will relight the new log once chat contains the message "The fire catches and the logs begin to burn" however I can't figure out how to grab the text from my chatbox. Hey @Vogelbekdier! You can achieve what you've set out to do using the "ChatListener" interface. Simply implement the ChatListener in your script and override the method you'd like to use. I've provided an example for you below. public class TestScript implements ChatListener { ... some code here ... @Override public void onGameMessage(Message message) { if (message.getMessage().contains("The fire catches and the logs begin to burn")) { shouldLightFire = true; } } } You can view all of the methods that can be overridden for ChatListener here: https://dreambot.org/javadocs/org/dreambot/api/script/listener/ChatListener.html You can view all of the information provided by a "Message" here: https://dreambot.org/javadocs/org/dreambot/api/wrappers/widgets/message/Message.html The different overrides are for the different types of message (game message, clan message, etc.). You can also use the catch-all "onMessage()" method. Hope that helps! Best of luck 🙂
choucter 1 Posted July 15, 2021 @Bonfire, thanks for the great information above. It's very helpful for us new guys trying to produce code to handle messages.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.