Concat localizations and ShowMessageText()

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Concat localizations and ShowMessageText()

Post 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.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Concat localizations and ShowMessageText()

Post 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.
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: Concat localizations and ShowMessageText()

Post by Teancum »

Dang. I figured as much. The SWBF1 executable must handle captures differently.
Master_Ben
Lieutenant General
Lieutenant General
Posts: 675
Joined: Wed Nov 12, 2008 9:50 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Watching your PC over your shoulder. No, the other sholder....

Re: Concat localizations and ShowMessageText()

Post 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 "".
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Concat localizations and ShowMessageText()

Post 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.
Post Reply