How does a bot read the chat window?

AI discussion, ideas, and SDK help.
Post Reply
User avatar
SunTzu
Lux Cartographer
Posts: 1585
Joined: Sat Jan 14, 2006 1:48 am
Location: Maryland

How does a bot read the chat window?

Post by SunTzu » Thu Aug 30, 2007 1:22 pm

There are several methods for sending text to the chat, but I haven't found any that can read the chat.

User avatar
RandomGuy
Lux Veteran
Posts: 1463
Joined: Mon Mar 05, 2007 12:02 am
Location: Central American Jungle
Contact:

Post by RandomGuy » Thu Aug 30, 2007 1:40 pm

you get an event message that you can parse and respond to however you like. I think the event is called "message".

Check out the Angry bot sample code for the syntax. You'll get passed an object with who said something and what they said.

User avatar
GregM
Luxer
Posts: 252
Joined: Wed Jun 01, 2005 4:33 pm

Post by GregM » Thu Aug 30, 2007 1:42 pm

This is done via the message() method in the LuxAgent interface, which is called in various circumstances (someone said something in the chat, or you just got attacked, or you just got eliminated). To read the chat do something like this:

Code: Select all

String message(String type, Object data) {
  if(!type.equals("chat")) return null;

  java.util.List lData = (java.util.List)data; //in this case data is a List object
  //not java.awt.List though!

  //the contents of the list are the sender and the message
  String sender = (String)lData.get(0);
  String message = (String)lData.get(1);

  if(sender.equals("SunTzu")) board.sendChat("Yes, sir!");

  if(message.contains(name())) board.sendChat("That's me!!");

  return null;
}

User avatar
blackj3sus
Lux Messiah
Posts: 3223
Joined: Fri May 05, 2006 12:27 pm
Location: sillysoft.net/roman-battles
Contact:

Post by blackj3sus » Thu Aug 30, 2007 3:05 pm

well they have to read it cause when u say bots 1st they freak out :roll:

User avatar
SunTzu
Lux Cartographer
Posts: 1585
Joined: Sat Jan 14, 2006 1:48 am
Location: Maryland

Post by SunTzu » Fri Aug 31, 2007 8:23 am

Thanks RandomGuy & GregM!

Post Reply