String as parameters

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

String as parameters

Post by enric »

If I remember well in BA1 there was no possible to use strings as parameter in mod functions, right?
Because this :

PlayTest("hello");

FUNCTION PlayTest(myString)
{
Log ("myString", myString);
}

prints 934237349

Is there a way I missed to pass strings as parameters in BA2?
pipfromslitherine
Site Admin
Site Admin
Posts: 9863
Joined: Wed Mar 23, 2005 10:35 pm

Re: String as parameters

Post by pipfromslitherine »

I THINK it will work if you pass it into a function which expects a string (Log doesn't, but something like PrintWorkLiteral would).

Cheers

Pip
follow me on Twitter here
pipfromslitherine
Site Admin
Site Admin
Posts: 9863
Joined: Wed Mar 23, 2005 10:35 pm

Re: String as parameters

Post by pipfromslitherine »

I THINK it will work if you pass it into a function which expects a string (Log doesn't, but something like PrintWorkLiteral would).

Cheers

Pip
follow me on Twitter here
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: String as parameters

Post by enric »

PrintWorkLiteral doesn't exist.

// PrintStringLiteral(myString);
// PrintString(myString);
// PrintWorkStringLiteral(myString);

Don't work, but the string is received because StringCompare works.

if ( StringCompare(myString, "hello") == 1)
{
Log("it works");
}
else
{
Log("it doesn't");
}
pipfromslitherine
Site Admin
Site Admin
Posts: 9863
Joined: Wed Mar 23, 2005 10:35 pm

Re: String as parameters

Post by pipfromslitherine »

I would expect PrintStringLiteral to work if StringCompare works. But nothing gets 'done' to the 'string' value as it passed through functions, so it should be able to be passed to any function which takes a string.

Cheers

Pip
follow me on Twitter here
Post Reply

Return to “Battle Academy 2: Modders Corner”