CP Message Code (FAQ)
Moderator: Moderators
-
- Old School Staff
- Posts: 2059
- Joined: Wed Feb 23, 2005 9:54 am
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
RE: CP Message Code
what's a Post Virual Syndrom? >.> is it a medical joke?
Isn't that done through the Localization? or maybe you can active a String in the .LUA* (you probably can - lol - but where would the string be displayed?)
Isn't that done through the Localization? or maybe you can active a String in the .LUA* (you probably can - lol - but where would the string be displayed?)
-
- Major
- Posts: 501
- Joined: Mon Apr 17, 2006 1:44 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
RE: CP Message Code
Maybe it is in the SWBF1 lua's? I should check those dude. But would the string be something like DisplayCommandPostName?
Soul
EDIT: There are is a infomsg into the Localization keys, that has a lost and captured key (like Penguin already said). Maybe we should use this too find out how to make the CP texts display again.
EDIT2: There are loads of commands in the GT wiki (donnu if its back up). Check those out, I'm pretty sure the command you need will be in the list.
EDIT3: I might have found it
Soul
EDIT: There are is a infomsg into the Localization keys, that has a lost and captured key (like Penguin already said). Maybe we should use this too find out how to make the CP texts display again.
EDIT2: There are loads of commands in the GT wiki (donnu if its back up). Check those out, I'm pretty sure the command you need will be in the list.
EDIT3: I might have found it
Code: Select all
assert(cp.name, "WARNING: no name supplied for the command post")
cp.name = string.lower(cp.name)
self.commandPosts[cp.name] = cp
Hidden/Spoiler:
- Teancum
- Jedi Admin
- Posts: 11079
- Joined: Wed Sep 07, 2005 11:42 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Indiana
RE: CP Message Code
The OnFinishCapture( ) function is what you want. From there you can get it to print a string.
Are you wanting this to be like it was in SWBF1 where text pops up when a CP is captured?
Are you wanting this to be like it was in SWBF1 where text pops up when a CP is captured?
-
- Major
- Posts: 501
- Joined: Mon Apr 17, 2006 1:44 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
RE: CP Message Code
Won't you also need the other codes, since you also get a message when you lost a CP in SWBF1 too.
Soul
Soul
- Teancum
- Jedi Admin
- Posts: 11079
- Joined: Wed Sep 07, 2005 11:42 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Indiana
RE: CP Message Code
True. Hadn't thought of that.
-
- Major
- Posts: 501
- Joined: Mon Apr 17, 2006 1:44 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
RE: CP Message Code
I've tried all of the functions. None of them worked, but that probably was because I didn't setup any localization for my cp's. Gonna try out in a few secs with correct localization keys.
Soul
Soul
-
- Jedi Admin
- Posts: 2541
- Joined: Sun Mar 05, 2006 12:00 am
- Location: Australia
RE: CP Message Code
have a feeling that I'm doing this the long/or wrong way
these lines are all for 1 cp. Haven't tested it yet >.< I've put them under
function ScriptInit()
these lines are all for 1 cp. Haven't tested it yet >.< I've put them under
function ScriptInit()
Code: Select all
OnFinishCaptureTeam(function (ShowMessageText("level.VNV.cp2c_r", ATT, DEF) (cp2) ... end, 1)
OnFinishCaptureTeam(function (ShowMessageText("level.VNV.cp2c_c", ATT, DEF) (cp2) ... end, 2)
OnFinishNeutralizeTeam(function (ShowMessageText("level.VNV.cp2l_r", DEF, ATT) (cp2) ... end, 1)
OnFinishNeutralizeTeam(function (ShowMessageText("level.VNV.cp2l_c", DEF, ATT) (cp2) ... end, 2)
- Teancum
- Jedi Admin
- Posts: 11079
- Joined: Wed Sep 07, 2005 11:42 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Indiana
RE: CP Message Code
It's probably going to have to go under PostLoad() ScriptInit() is ran while the level is loading to get all the assets ready.
-
- Old School Staff
- Posts: 2059
- Joined: Wed Feb 23, 2005 9:54 am
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
RE: CP Message Code
that's in the .LUA then I'm pretty sure I've seen something alike when i Localized.
-
- Jedi Admin
- Posts: 2541
- Joined: Sun Mar 05, 2006 12:00 am
- Location: Australia
RE: CP Message Code
they still got the BF1 localiztion.
still no help. I'm complety stuck. Maybe an expert coder could help me with this simple code?
still no help. I'm complety stuck. Maybe an expert coder could help me with this simple code?
-
- Old School Staff
- Posts: 2059
- Joined: Wed Feb 23, 2005 9:54 am
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Teancum
- Jedi Admin
- Posts: 11079
- Joined: Wed Sep 07, 2005 11:42 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Indiana
OFF-TOPIC (sort of)
ON-TOPIC
Here's a "grunt-work" way of doing it...
Now there "should" be a better way of doing this; like having a delimited string that is filled in with other localized strings at runtime. However, I have only seen the exe do stuff like that, and haven't seen any evidence of a way to do it through the Lua interface. Mind you, all because I haven't seen any evidence, doesn't mean there isn't a way; only that it was never done in the scripts I've looked through.
P.S.
I wrote the code up quickly and haven't tested it. If there is a syntax error or something, just message me about it.
Nah, all Lua scripts are treated the same way by the game engine. The only "special" situation is where a script is called by the exe: in that case only the name of the script file and the functions it contains have to have the correct names, and must do what is expected of them (mostly interface stuff). Any scripts read in by ScriptCB_DoFile() are not called by the exe 'directly', but by the Lua interface/engine instead. The only time you need to edit those scripts is when you are using them yourself, but they are doing something "unwanted".Teancum wrote:Oh duh lolz--- it probably needs to be in ObjectiveConquest.lua
ON-TOPIC
Here's a "grunt-work" way of doing it...
Code: Select all
-- This would go into ScriptPostLoad()
-- and you would have one for each team capturing CPs
OnFinishCaptureTeam(
function(cPost)
local pName = GetEntityName(cPost) -- Gets the name of the post that was captured
ShowMessageText("level.VNV." .. pName .. "_r") -- Show this string to all teams
end,
teamNumber -- Team number for the strings
)
-- the ".." is Lua's concatenate, ie connecting two strings together
-- If the post's name was "cp1" then the line above should create "level.VNV.cp1_r"
-- Just make sure you have a localized string for each side and CP otherwise it will show as "NULL"
P.S.
I wrote the code up quickly and haven't tested it. If there is a syntax error or something, just message me about it.
-
- Major
- Posts: 501
- Joined: Mon Apr 17, 2006 1:44 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Teancum
- Jedi Admin
- Posts: 11079
- Joined: Wed Sep 07, 2005 11:42 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Indiana
Teancum's correct. The concatenated string (which works in a "semi-automatic" fashion) is a cleaner way of doing it, instead of having a bunch of "if" and "elseif" statements strung together (in my opinion anyway). Also, don't forget to change the teamNumber to the team the listener (the "On" call) is for.
Here's how that function works (step-by-step):
1- CP "cp2" is captured by team 1
2- The function pointed to by OnFinishCaptureTeam() that was watching for team 1 captures is called. The pointer to the CP is also passed to the function. Note: I use the term "pointers", but really they are just reference numbers used by the exe in the background.
3- "local pName = GetEntityName(cPost)" creates a temporary variable called pName and sets it to the name of the CP that was captured. So now pName = "cp2".
4- ShowMessageText("level.VNV." .. pName .. "_r") is executed by the Lua engine in a two-step process. First it concatenates the string inside the brackests. So it takes the first string "level.VNV." combines it with pName then combines that combo with "_r". In this case it would create: "level.VNV.cp2_r".
5- ShowMessageText() is now called using the new string. So it acts like a ShowMessageText("level.VNV.cp2_r") call.
6- ShowMessageText() goes to the localization database, grabs the localizer string "level.VNV.cp2_r", then spits it out onto the screen.
7- Game execution continues...
It may seem a little confusing, but read it over a few times. I tried to be as clear as I could, but I'm often terrible at explaining things like this.
Here's the code again since this post is on a different page:
Here's how that function works (step-by-step):
1- CP "cp2" is captured by team 1
2- The function pointed to by OnFinishCaptureTeam() that was watching for team 1 captures is called. The pointer to the CP is also passed to the function. Note: I use the term "pointers", but really they are just reference numbers used by the exe in the background.
3- "local pName = GetEntityName(cPost)" creates a temporary variable called pName and sets it to the name of the CP that was captured. So now pName = "cp2".
4- ShowMessageText("level.VNV." .. pName .. "_r") is executed by the Lua engine in a two-step process. First it concatenates the string inside the brackests. So it takes the first string "level.VNV." combines it with pName then combines that combo with "_r". In this case it would create: "level.VNV.cp2_r".
5- ShowMessageText() is now called using the new string. So it acts like a ShowMessageText("level.VNV.cp2_r") call.
6- ShowMessageText() goes to the localization database, grabs the localizer string "level.VNV.cp2_r", then spits it out onto the screen.
7- Game execution continues...
It may seem a little confusing, but read it over a few times. I tried to be as clear as I could, but I'm often terrible at explaining things like this.
Here's the code again since this post is on a different page:
Code: Select all
-- This would go into ScriptPostLoad()
-- and you would have one for each team capturing CPs
OnFinishCaptureTeam(
function(cPost)
local pName = GetEntityName(cPost) -- Gets the name of the post that was captured
ShowMessageText("level.VNV." .. pName .. "_r") -- Show this string to all teams
end,
teamNumber -- Team number for the strings (don't forget to change me)
)
-- the ".." is Lua's concatenate, ie connecting two strings together
-- If the post's name was "cp1" then the line above should create "level.VNV.cp1_r"
-- Just make sure you have a localized string for each side and CP otherwise it will show as "NULL"
-
- Jedi Admin
- Posts: 2541
- Joined: Sun Mar 05, 2006 12:00 am
- Location: Australia
-
- Major
- Posts: 501
- Joined: Mon Apr 17, 2006 1:44 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set