Jump to content
Sign in to follow this  
theavonlady

Placing a variable in Stringtable.csv

Recommended Posts

It must be so simple. That's why I didn't find anything when I searched for this.

I've got a global string variable defined in init.sqs: _town = "Houdan"

How can I get variable _town to display in a radio text message defined in the mission's Stringtable.csv file? rock.gif

TIA! smile_o.gif

Share this post


Link to post
Share on other sites

stringtable:

STR_Speedlimit, "Attention, speedlimit is %1kph!"

Script:

hint Format [localize "STR_Speedlimit",speed plane]

Share this post


Link to post
Share on other sites

init.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">TOWN = ["Houdan"]

stringtable.csv

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[snip]....format ["%1", (TOWN select 0)]...[snip]

yes?

Share this post


Link to post
Share on other sites
)a)( @ Sep. 20 2004,14:11)]stringtable:

STR_Speedlimit, "Attention, speedlimit is %1kph!"

Script:

hint Format [localize "STR_Speedlimit",speed plane]

Hmmm.... an example a little more complicated than mine. Would my specific example be coded as follows?

STR_IngressTown,"You will be airlifted to %1."

Script:

hint Format [localize "STR_IngressTown",_town]

BTW, why is "hint" needed? rock.gif

Or is that just to display the variable?

Share this post


Link to post
Share on other sites
init.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">TOWN = ["Houdan"]

Isn't an underscore required before the word "town" in both init.sqs and in Stringtable.csv? rock.gif

EDIT: This method didn't work. The radio message showed up as "format[".

EDIT: Neither method is working for me. I tried playing around with the syntax and nothing helped. sad_o.gif

In general, Zayfod's method would be preferable because I have numerous messages where I want to do this and I'd rather put the format statement directly into the radio message text instead of coding numerous format statements in init.sqs.

HELP! sad_o.gif

Share this post


Link to post
Share on other sites

Stringtable.csv:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">LANGUAGE,English,German

STR_AVON_ADVANCING,"We're advancing on %1, over and out.","Wir nähern uns %1, Ende und Aus."

You can use any name for the variable instead of STR_AVON_ADVANCING.

The stringtable.csv is generally ment to contain translations of the different texts. In the first row you define which languages you'll support and their order. I made my example for English and German.

Your radio command had to be like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">player sideChat format [localize "STR_AVON_ADVANCING", _town]

IMPORTANT: Note that "_town" IS NOT a global variable, it's local. Global would be for example "town", without underscore.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">localize "MY_STRINGTABLE_STRING"

returns the string of the stringtable at MY_STRINGTABLE_STRING in the right language.

EDIT: some code mistakes

EDIT 2: Damn I misread everything! Sorry Avon, corrected now.

Share this post


Link to post
Share on other sites

Let me clarify what I need.

The town name is initialized to "Houdan" at mission start but a trigger might change it to another town name. The variable town name will appear in many radio messages.

EDIT: OK. Checking possibilities. Thanks for warning me about the underscore.

Share this post


Link to post
Share on other sites

Nothing works! Here's what I have:

In init.sqs:

Quote[/b] ]town = "Houdan"

In various action triggers in mission.sqm:

Quote[/b] ]town = "Dourdan"

town = "Lolisse"

town = "Vigny"

town = "La Pessagne"

In stringtable.csv (where "%1" is supposed to be the current value of variable "town":

Quote[/b] ]msg1,Approaching %1.

msg2,%1 captured.

msg3,Retreating from %1.

What's missing? rock.gifsad_o.gif

Share this post


Link to post
Share on other sites
What's missing? rock.gif  sad_o.gif

Here's the whole stringtable.csv:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Language,English

msg1,"Approaching %1."

msg2,"%1 captured."

msg3,"Retreating from %1."

and then you can use<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">hint format[localize "msg1",town]

player globalchat format[localize "msg1",town]tested

Or do you want to use xxxRadio commad? If so, do you have radio messages defined in the description.ext ?

Share this post


Link to post
Share on other sites
Or do you want to use xxxRadio command?

Yes!

Quote[/b] ]If so, do you have radio messages defined in the description.ext ?

Yes! And the radio message texts are in stringtable.csv.

Share this post


Link to post
Share on other sites

Why didn't you say that with the radio messages in description.ext earlier? smile_o.gif (hopes that he didn't overread something)

Then, hm. I think that's not really possible, because every radio message that you define in your description.ext once can't be changed anymore (correct me if I'm wrong). Of course you can use stringtable texts in the description.ext, just insert a $STR_MY_STRING (stringtable string with a $) where you had to insert the text. But it's AFAIK not possible to combine radio messages (as long it's defined in description.ext) with dynamic variables.

Uh, hope you get what I mean smile_o.gif

Share this post


Link to post
Share on other sites
Why didn't you say that with the radio messages in description.ext earlier? smile_o.gif  (hopes that he didn't overread something)

To clarify, the description.ext entry for such a message points to the text being in Stringtable.csv. Example:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> class radiomsg1

{

name="radionmsg1";

sound[]={"\Radio\msg01.ogg",1.000000,1.000000};

title=MSG1;

};

"Title" refers to this entry in Stringtable.csv:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">msg1,"Approaching %1."

"%1" needs to display the current value of the global variable "town".

The message would be issued by something like this command:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">leader sideRadio ""radiomsg1""

Share this post


Link to post
Share on other sites

How I said, in description.ext and config.cpp you need a $ to refer to a stringtable variable. Correctly it would look that way:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> class radiomsg1

{

name="radionmsg1";

sound[]={"\Radio\msg01.ogg",1.000000,1.000000};

title="$MSG1";

}

while I'm not sure if "$MSG1" is with or without quotes, you gotta try that out.

AFAIK it's not possible to combine radio messages defined in the description.ext with dynamic variables, in your case "town".

BUT you could try another thing. Like it seems the sound for the message is always the same, independent from the town you're referring to (Otherwise you had to change the sound path too, which is not possible).

You could try to leave the title value empty, e.g. title=""; or title=;

Once you send your radio message, you could write it like that:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">leader sideChat format [localize "MSG1",town]

leader sideRadio "radiomsg1"

First it would write the line containing the town name on the screen, and at the same moment your sound would be played. Dunno if it works though, good luck wink_o.gif

Share this post


Link to post
Share on other sites
How I said, in description.ext and config.cpp you need a $ to refer to a stringtable variable.

Sorry. Yes, messages all have $ prefix in description.ext.

Quote[/b] ]while I'm not sure if "$MSG1" is with or without quotes, you gotta try that out.

I have it with quotes and my messages are appearing - except for getting a variable string in them.

Quote[/b] ]AFAIK it's not possible to combine radio messages defined in the description.ext with dynamic variables, in your case "town".

I would have thought that variables in messages would be elementary. sad_o.gif

Quote[/b] ]BUT you could try another thing. Like it seems the sound for the message is always the same, independent from the town you're referring to (Otherwise you had to change the sound path too, which is not possible).

You could try to leave the title value empty, e.g. title=""; or title=;

Once you send your radio message, you could write it like that:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">leader sideChat format [localize "MSG1",town]

leader sideRadio "radiomsg1"

First it would write the line containing the town name on the screen, and at the same moment your sound would be played. Dunno if it works though, good luck wink_o.gif

This is too mangled a method.

If anyone from BIS sees this, either:

1) tell us how to incorporate variables into stringtable.csv radio message texts

or

2) put this ability on your OFP2-to-do-list.

If there is no simple solution, I'm going over to the message prefixing method I'm discussing on a separate thread. I hope something there will work out. sad_o.gif

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×