Home   Help Search Login Register  

Author Topic: stringtable,description.ext using variables  (Read 1078 times)

0 Members and 1 Guest are viewing this topic.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
stringtable,description.ext using variables
« on: 27 Jan 2006, 00:09:10 »
I want to define a cfgRadio in my description.ext

The sound will be the same each time(a clock ticking) but I want to be able to embed a variable for the display text.

Say I want the text formatted like this:
format["%1 seconds left",_timeleft]

Here is the cfgRadio entry:
Code: [Select]
   class timeleft
   {
   name = "timeleft";
   sound[] = {"ticktock.ogg",db-0,1.0};
   title = $STR_TIMELEFT;
   };

What would my stringtable entry be, and how would I get it to work with the sideRadio command with the global variable smb_TimeLeft?

Normally, _man sideRadio "timeleft", would do it.
urp!

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:stringtable,description.ext using variables
« Reply #1 on: 27 Jan 2006, 03:54:04 »
have you had a look through this?

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:stringtable,description.ext using variables
« Reply #2 on: 27 Jan 2006, 09:17:48 »
This may not be possible. If it is, I would reckon you can't do it directly thru a stringtable. If you can, it would most likely look like this:

Code: [Select]
  class timeleft
   {
   name = "timeleft";
   sound[] = {"ticktock.ogg",db-0,1.0};
   title = TIME_LEFT;
   };

Now in your mission, "TIME_LEFT" will be defined as a global variable of string type. So in the same script you call the radio command repeatedly, you would also want to format the string to be used (TIME_LEFT = format["%1 seconds left",_timeleft]).

If you wanted to, you could use the "localize" command to get the "seconds left" part of that above string.

Again, I'm not sure if this would work, but apparently you can use global variables in a similar way for different things inside the description.ext (dialogs for example).
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:stringtable,description.ext using variables
« Reply #3 on: 27 Jan 2006, 13:31:29 »
I have read the stringtable resource; I might just be buggering something up (again!) :)

The reason I am asking is because I am trying to exclusively use the stringtable for my mission text to allow internationalisation, should I ever get around to it.

From what you have said, it seems that you can not access a stringtable value directly.  Let's say I wanted to use a stringtable value in a hint:
Code: [Select]
hint $STR_DUMDUMand
Code: [Select]
hint format["%1",$STR_DUMDUM]or
Code: [Select]
hint format[$STR_DUMDUM]do not work. Or what if I want to compare a variable string to a value in the stringtable?

I guess the more general question would be is it possible to access stringtable values while a mission is running?
« Last Edit: 27 Jan 2006, 15:59:32 by Mr.Peanut »
urp!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:stringtable,description.ext using variables
« Reply #4 on: 27 Jan 2006, 16:02:44 »
Okay. Now I see how to do it. Never knew of the localize command before, but it seems to be what I was looking for.
Thanks
urp!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:stringtable,description.ext using variables
« Reply #5 on: 27 Jan 2006, 23:03:55 »
 :'(

urp,

Well it didn't work.

Here is my stringtable value:
Code: [Select]
STR_DRIVERDEAD,Convoy Driver Killed. %1 drivers remaining.
Here is my cfg from my description.ext :
Code: [Select]
class CfgRadio
{
   sounds[] = {driverdead};
   class driverdead
   {
   name = "driverdead";
   sound[] = {"static.ogg",db-0,1.0};
   title = smb_DriverDeadString;
   };
};

And my snippet:
Code: [Select]
smb_DriverDeadString = format[localize "STR_DriverDead",_n]
leader gwd sideRadio "driverdead"

However, all it does is:

Bravo Black1: smb_DriverDead

It is interpreting the variable as a string literal in the description.ext

I guess this means I'm screwed unless someone knows a coercion trick or two. I can't understand this because in the game itself, OFP concatenates sounds (and strings) together all the time e.g. "6, target machine gunner at 12 o'clock".


« Last Edit: 27 Jan 2006, 23:09:03 by Mr.Peanut »
urp!