OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Mr.Peanut 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:
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.
-
have you had a look through this (http://www.ofpec.com/editors/resource_view.php?id=913)?
-
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:
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).
-
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:
hint $STR_DUMDUMand
hint format["%1",$STR_DUMDUM]or
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?
-
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,
Well it didn't work.
Here is my stringtable value:
STR_DRIVERDEAD,Convoy Driver Killed. %1 drivers remaining.
Here is my cfg from my description.ext :
class CfgRadio
{
   sounds[] = {driverdead};
   class driverdead
   {
   name = "driverdead";
   sound[] = {"static.ogg",db-0,1.0};
   title = smb_DriverDeadString;
   };
};
And my snippet:
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".