Author Topic: Displaying An Variable In Tethysgame::addmessage  (Read 1825 times)

Offline Mcshay

  • Administrator
  • Sr. Member
  • *****
  • Posts: 404
Displaying An Variable In Tethysgame::addmessage
« on: April 23, 2006, 06:34:43 PM »
I've been wondering how to take for example, "int TheInt = 1;" and place that in this function "TethysGame::AddMessage(int pixelX, int pixelY, char *message, int recipientPlayerNum, int soundID);". Is there a way to do it?

Offline BlackBox

  • Administrator
  • Hero Member
  • *****
  • Posts: 3093
Displaying An Variable In Tethysgame::addmessage
« Reply #1 on: April 23, 2006, 09:10:05 PM »
Something like this would work:

Code: [Select]
int var=30;
char buffer[200];

// format a string in buffer. %i is a placeholder that means 'integer', the next argument will be used to replace it
scr_snprintf(buffer, 200, "var = %i", var);

// should read "var = 30"
TethysGame::AddMessage(-1, -1, buffer, 0, 0);

Offline Mcshay

  • Administrator
  • Sr. Member
  • *****
  • Posts: 404
Displaying An Variable In Tethysgame::addmessage
« Reply #2 on: April 25, 2006, 08:51:12 PM »
Thanks.