Chat help requested

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

Chat help requested

Post by SunTzu » Thu Sep 13, 2007 3:51 pm

If I only want to send a chat once per Lux session, where would I put it?

I tried it in Defender(), but Lux won't load the bot then. I also tried it setPrefs, but I didn't want the chat sent at the beginning of every game.

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

Post by RandomGuy » Thu Sep 13, 2007 3:59 pm

can you send it in setprefs and then store a value in persistent storage that the chat message was sent? Then you could check the value in storage before sending (it would skip it all future games) until lux was restarted...

User avatar
Bertrand
Reaper Creator
Posts: 568
Joined: Mon Nov 28, 2005 4:35 pm
Location: Montreal

Post by Bertrand » Thu Sep 13, 2007 6:03 pm

Do you know about static variables? Only one instance exists for the class, and it will remain for the whole lux session.

Declare a global static like this:

static boolean helpMsg = false;

Then, somewhere in placeArmies(), insert this code:

Code: Select all

        if (!helpMsg)
        {
            helpMsg = true;
            board.sendChat("Read this human, or else.");
        }
 
The message will be issued once per session, even if multiple copies of the AI are playing.

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

Post by SunTzu » Thu Sep 13, 2007 8:13 pm

Thanks! I'll give that a try Bertrand.

RandomGuy's suggestion would have worked if persistent storage didn't work across multiple sessions.

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

Post by RandomGuy » Thu Sep 13, 2007 8:36 pm

Good to know - I thought that Lux reset those values at each startup.

User avatar
guest
Luxer
Posts: 189
Joined: Fri Dec 17, 2004 9:17 pm
Location: Southern NH
Contact:

Post by guest » Fri Sep 14, 2007 12:31 am

Sure thats why you store a date & time in the persistant store.

Post Reply