I am working a a gamescript, and I have issue to understand something about variables GSText.
First of all, I want to display information on GSTown (SetText method)
information will be dynamically generated : the number of lines and content of lines themselves.
to begin, let's say we have two kind of lines only to display, I maintained in english.txt file
Code: Select all
STR_TOWN_CARGO_FIGURES :{YELLOW}{CARGO_LIST}{BLACK} n:{BLUE}{NUM}{BLACK} n-1:{BLUE}{NUM}{BLACK} n-2:{BLUE}{NUM}{BLACK}
STR_TOWN_BONUS_INFO :{GREEN}BONUS {NUM}{BLACK}
STR_TOWN_EMPTY_LINE :{LTBROWN}- - - - - - -{BLACK}
Code: Select all
GSText(GSText["STR_TOWN_BONUS_INFO",100])
and
cargo=1<<cargoid;
q0=100; q1=100;q2=100;
GSText(GSText["STR_TOWN_CARGO_FIGURES"],cargo,q0,q1,q2);
I have to create a {STRING}{}{STRING}{}{STRING}... text, but then I must take into account the number of variable I am using in sub-texts,
let's say STR_TOWN_CARGO_FIGURES lines will be used first... it consumes 4 variables (cargo,q0,q1,q2), then I should use {STRING4}.
Code: Select all
STR_TOWN_ALL_LINES :1.{STRING4}{}2.{STRING4}{}3.{STRING4}{}4.{STRING4}{}5.{STRING4}{}6.{STRING4}{}7.{STRING4}{}8.{STRING4}{}9.{STRING4}{}10.{STRING4}
but you see STR_TOWN_EMPTY_LINE wont consume 4 variables... and what when I will need to add a STR_TOWN_BONUS_INFO line ?
here is an example of code
Code: Select all
line[0] <- GSText(GSText["STR_TOWN_CARGO_FIGURES"],1<<0,100,100,100); // 0:passengers
line[1] <- GSText(GSText["STR_TOWN_CARGO_FIGURES"],1<<2,200,200,200); // 2:mails
i=2;
while(i<=9)
{
line[i++] <- GSText(GSText["STR_TOWN_EMPTY_LINE"]);
}
local txt=GSText(GSText["STR_TOWN_ALL_LINES"],line[0],line[1],line[2],line[3],line[4],line[5],line[6],line[7],line[8],line[9]);
GSTown.SetText(townid,txt);
result is
Code: Select all
1. Passengers n:100 n-1:100 n-2:100
2. Mails n:200 n-1:200 n-2:200
3.- - - - - - - - -
4.- - - - - - - - -
5.
6.
7.
8.
9.
10.
this is probably because STR_TOWN_EMPTY_LINE does not consumes 4 variables,
That's already weird...
remember I will need to have non-homogeneous line (bonus with only 1 parameter)
BUT... it's not the only issue,
I don't need to go further...
when using more STR_TOWN_CARGO_FIGURES string lines we have other issues:
using 5 STR_TOWN_CARGO_FIGURES => the whole GSTown.SetText does not work, no error, simply no action.
using 4 STR_TOWN_CARGO_FIGURES => the STR_TOWN_EMPTY_LINE are pushed back to line 10,
see:
Code: Select all
line[0] <- GSText(GSText["STR_TOWN_CARGO_FIGURES"],1<<0,100,100,100); // 0:passengers
line[1] <- GSText(GSText["STR_TOWN_CARGO_FIGURES"],1<<2,200,200,200); // 2:mails
line[2] <- GSText(GSText["STR_TOWN_CARGO_FIGURES"],1<<1,100,100,100); // 1:alcohol
line[3] <- GSText(GSText["STR_TOWN_CARGO_FIGURES"],1<<3,100,100,100); // 3:chemical
i=4
while(i<=9)
{
line[i++] <- GSText(GSText["STR_TOWN_EMPTY_LINE"]);
}
local txt=GSText(GSText["STR_TOWN_ALL_LINES"],line[0],line[1],line[2],line[3],line[4],line[5],line[6],line[7],line[8],line[9]);
GSTown.SetText(townid,txt);
Code: Select all
1. Passengers n:100 n-1:100 n-2:100
2. Mails n:200 n-1:200 n-2:200
3. Alcohol n:100 n-1:100 n-2:100
4. Chemical n:100 n-1:100 n-2:100
5.
6.
7.
8.
9.
10.- - - - - - - - -
I don't know what is wrong, you help is welcomed.
Sorry for long message, I tested as much as I could before asking your help here...
I am wondering if there is a method maybe to "consolidate string and all its parameters" to make it fit into a simple {STRING} on higher level
something like that
Code: Select all
line[0] <- GSText(GSText["STR_TOWN_FIGURES"]);
line[0].SetParam(1,1<<0); // 0:passengers
line[0].SetParam(2,100);
line[0].SetParam(3,100);
line[0].SetParam(4,100);
line[0].MakeThisStringSOLID_Please(); // I want to use line[0] as a {STRING}, not a {STRING4} ...