Strings

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Strings

Post by enric »

We can make a call to a function like:

myFunction (4, "Sherman", 23);

So the function receives a string as the second parameter.

Function myFunction (x, type, y)

So type contain a string and:
if( IsUnitType(id, type) == 1)
seems to work.

BUT, we can not define

Type = "Sherman";

Is there a way to deal with strings?
pipfromslitherine
Site Admin
Site Admin
Posts: 9928
Joined: Wed Mar 23, 2005 10:35 pm

Re: Strings

Post by pipfromslitherine »

If you want strings to use in that way you need to build them using the work string functions. There is no intinsic string type in the scripting - it's on my list as it would be very useful, but not done.

So for now, it's via StartWorkString etc.

Cheers

Pip
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Re: Strings

Post by enric »

Can you, please, put an example of
StartWorkString([index]);

This don't work

Width = GetMapWidth();
StartWorkString();
PrintWorkStringInt(Width);
ShowTextMarker(1, 43, 16, GetWorkString();, 6, "FFFFFF", 1);
pipfromslitherine
Site Admin
Site Admin
Posts: 9928
Joined: Wed Mar 23, 2005 10:35 pm

Re: Strings

Post by pipfromslitherine »

ShowTextMarker also requires an IDS_ type defined string, not a generic string. Also, the Work string is a char string (that is, non-unicode) which is what is used for the function string parameters, whereas the StartString() type strings are unicode strings which are actually used for showing things (so for the DrawScenarioUI function RenderString you use StartString not StartWorkString functions).

To put it another way, use StartString for something you are going to show, and StartWorkString for something the system is going to use (like a filename, a unit type, etc).

Cheers

Pip
Post Reply

Return to “Battle Academy : Modders Corner ”