Page 1 of 1

Concat localizations and ShowMessageText()

Posted: Thu Dec 31, 2009 9:36 am
by Teancum
I'm just toying around with ideas at work, but I'm trying to find an easy, global way of doing SWBF1-style CP capture descriptions.

Here's the current code:
--To go in ObjectiveClassicConquest.lua

OnFinishCaptureTeam(
function(cPost)
local cpName = GetEntityName(cPost) -- Gets the name of the post that was captured
local cpTeam = GetCommandPostTeam(cPost) --Gets the team name

ShowMessageText("level.ZZZ.capture." .. pName .. cpTeam) -- Show this string to all teams
end,
)

-- Result: Output the value of level.ZZZ.capture.CP1CIS
And here's what I'd like to do:
--To go in ObjectiveClassicConquest.lua

OnFinishCaptureTeam(
function(cPost)
local cpName = GetEntityName(cPost) -- Gets the name of the post that was captured
local cpTeam = GetCommandPostTeam(cPost) --Gets the team name

ShowMessageText("The " & "entity.sides." ..cpTeam & " captured the " & .. pName) -- Show this string to all teams
end,
)

-- Result: A dynamic string, with some static text, and some localization, with the end result being something like "The CIS captured the Spire".
Trouble is, I don't think you can do raw text with ShowMessageText(), and I doubt can you use the & symbol to create a dynamic sting like in VB.net. There must have been something like this in the SWBF1 code. I know they didn't localize every instance, just the side, the "captured the" and the CP name. Any ideas? I'd really hate to localize every capture and nuetralize for every CP/map/faction.

Re: Concat localizations and ShowMessageText()

Posted: Thu Dec 31, 2009 1:43 pm
by Maveritchell
You can't really mix message texts like that (localize keys must be pre-defined); I remember playing around with this a lot when I was trying to set up an ingame save code for this map.

I worked around it by using separate instances of ShowMessageText:

Code: Select all

ShowMessageText("level.cmn.cis")
ShowMessageText("level.GO1.cp1")
To get:
The CIS captured the
Spire
It's not ideal because of the way the messagetext box scrolls, but since you can't do any more than just choose strings for ShowMessageText, it's really your only option if you want to go that route.

Re: Concat localizations and ShowMessageText()

Posted: Thu Dec 31, 2009 1:53 pm
by Teancum
Dang. I figured as much. The SWBF1 executable must handle captures differently.

Re: Concat localizations and ShowMessageText()

Posted: Thu Dec 31, 2009 2:01 pm
by Master_Ben
Of course, you could go all the way and waste a decent amount of codespace, and type up "The CIS captured CP 1", "The CIS captured CP 2", etc...

Could you use this somehow? The game does pull off (at least in BFII, I'm not sure about 1,) dynamic strings, customizing message texts to fit control setups:
Hidden/Spoiler:
Image
Sorry for the big image, stupid second monitors.....

It's unlikely that you could pull it off, but it's worth a shot, right? :wink:
Just use {} instead of "".

Re: Concat localizations and ShowMessageText()

Posted: Thu Dec 31, 2009 2:12 pm
by Maveritchell
Master_Ben wrote:Of course, you could go all the way and waste a decent amount of codespace, and type up "The CIS captured CP 1", "The CIS captured CP 2", etc...
That's what he was initially talking about that he said he didn't want to do. (The first code he shows does that.)
Master_Ben wrote:Could you use this somehow? The game does pull off (at least in BFII, I'm not sure about 1,) dynamic strings, customizing message texts to fit control setups:
Hidden/Spoiler:
Image
Sorry for the big image, stupid second monitors.....
It's unlikely that you could pull it off, but it's worth a shot, right? :wink:
Just use {} instead of "".
That is how the game does it for things like choosing units, but - at least when I looked into it about a year ago for that map - I don't know how or if that can be carried over. I did play around with it a tiny bit with no success and just left it at that. I could be wrong and maybe Tean could invest some time looking into it.