Added new era, now dark times is messed up [Keep]

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

Major
User avatar
Posts: 505
Joined: Wed Dec 31, 2008 1:54 pm
Location: Pax Empiricae; check WIP

Added new era, now dark times is messed up [Keep]

Postby impspy » Tue Sep 08, 2009 12:42 pm

So I added a new era (Empire Era) to the stock Coruscant map. The map starts fine, but instead of Darktimes being the third mode it is +123 Clone Wars?! What is going on, it worked until I renamed my Era. It is still dark times on the other maps

my addme
Hidden/Spoiler:
Code: Select all
--Search through the missionlist to find a map that matches mapName,
--then insert the new flags into said entry.
--Use this when you know the map already exists, but this content patch is just
--adding new gamemodes (otherwise you should just add whole new entries to the missionlist)
function AddNewGameModes(missionList, mapName, newFlags)
for i, mission in missionList do
if mission.mapluafile == mapName then
for flag, value in pairs(newFlags) do
mission[flag] = value
end
end
end
end


--insert the new gamemodes or maps here for pre-existing maps:

AddNewGameModes(sp_missionselect_listbox_contents,
"cor1%s_%s",
{era_l = 1, mode_con_l = 1, change = {
      era_l = { name="Empire Era", icon2="exGCW_icon" },
      },})

-- MULTIPLAYER

AddNewGameModes(mp_missionselect_listbox_contents,
"cor1%s_%s",
{era_l = 1, mode_con_l = 1, change = {
      era_l = { name="Empire Era", icon2="exGCW_icon" },
      },})

-- associate this mission name with the current downloadable content directory
-- (this tells the engine which maps are downloaded, so you need to include all new mission lua's here)
-- first arg: mapluafile from above
-- second arg: mission script name
-- third arg: level memory modifier. the arg to LuaScript.cpp: DEFAULT_MODEL_MEMORY_PLUS(x)

AddDownloadableContent("COR1","cor1l_con",4)
AddDownloadableContent("DAG1","dag1l_con",4)
AddDownloadableContent("DEA1","dea1l_con",4)
AddDownloadableContent("END1","end1l_con",4)
AddDownloadableContent("FEL1","fel1l_con",4)
AddDownloadableContent("GEO1","geo1l_con",4)
AddDownloadableContent("HOT1","hot1l_con",4)
AddDownloadableContent("KAM1","kam1l_con",4)
AddDownloadableContent("KAS2","kas2l_con",4)
AddDownloadableContent("MUS1","mus1l_con",4)
AddDownloadableContent("MYG1","myg1l_con",4)
AddDownloadableContent("NAB2","nab2l_con",4)
AddDownloadableContent("POL1","pol1l_con",4)
AddDownloadableContent("TAN1","tan1l_con",4)
AddDownloadableContent("TAT2","tat2l_con",4)
AddDownloadableContent("TAT3","tat3l_con",4)
AddDownloadableContent("UTA1","uta1l_con",4)
AddDownloadableContent("YAV1","yav1l_con",4)

-- all done
newEntry = nil
n = nil

-- Now load our core.lvl into the shell to add our localize keys
-ReadDataFile("..\\..\\addon\\p4i\\data\\_LVL_PC\\core.lvl")

Imperial Systems Expert
User avatar
Posts: 2493
Joined: Wed Mar 25, 2009 4:15 pm
Projects :: A secret project
Games I'm Playing :: Warframe STO

Re: added new era, now dark times is messed up

Postby kinetosimpetus » Tue Sep 08, 2009 1:43 pm

Mav used the "change" parameters in the Dark Times, "change" will only be used from one addme, so to make it work, you have to add the "change" parameters from The Dark Times to your addme as well.

Major
User avatar
Posts: 505
Joined: Wed Dec 31, 2008 1:54 pm
Location: Pax Empiricae; check WIP

Re: added new era, now dark times is messed up

Postby impspy » Tue Sep 08, 2009 1:57 pm

oh ok like this:

Code: Select all
AddNewGameModes(sp_missionselect_listbox_contents,
"cor1%s_%s",
{era_l = 1, era1=1,  mode_con_l = 1, change = {
      era_l = { name="Empire Era", icon2="exGCW_icon" },
      },} change = {
      era_1 = { name="Dark Times", icon2="darktimes_icon" },
      },)

-- MULTIPLAYER

AddNewGameModes(mp_missionselect_listbox_contents,
"cor1%s_%s",
{era_l = 1, era1=1,  mode_con_l = 1, change = {
      era_l = { name="Empire Era", icon2="exGCW_icon" },
      },} change = {
      era_1 = { name="Dark Times", icon2="darktimes_icon" },
      }, )


deit no that didn't work, now an error occurs when i munge addme

Sith Master
User avatar
Posts: 2786
Joined: Mon Jun 12, 2006 3:46 pm

Re: added new era, now dark times is messed up

Postby Xavious » Tue Sep 08, 2009 3:11 pm

You're using the change parameter twice. You can only use it once.

Major
User avatar
Posts: 505
Joined: Wed Dec 31, 2008 1:54 pm
Location: Pax Empiricae; check WIP

Re: added new era, now dark times is messed up

Postby impspy » Tue Sep 08, 2009 3:37 pm

so i can either have Empire era or Dark Times but not both :(

Sith Master
User avatar
Posts: 2786
Joined: Mon Jun 12, 2006 3:46 pm

Re: added new era, now dark times is messed up

Postby Xavious » Tue Sep 08, 2009 3:38 pm

No, you just combine the two change parameters into one. You're using it twice for the same map right now.

Jedi
User avatar
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: added new era, now dark times is messed up

Postby Frisbeetarian » Tue Sep 08, 2009 3:40 pm

Though you can only use the change parameter once, I think you can have as many arguments in it as you want. For example:
Code: Select all
change = {
      era_l = { name="Empire Era", icon2="exGCW_icon" },
      era_1 = { name="Dark Times", icon2="darktimes_icon" }
      }

Major
User avatar
Posts: 505
Joined: Wed Dec 31, 2008 1:54 pm
Location: Pax Empiricae; check WIP

Re: added new era, now dark times is messed up

Postby impspy » Tue Sep 08, 2009 3:45 pm

Frisbeetarian wrote:Though you can only use the change parameter once, I think you can have as many arguments in it as you want. For example:
Code: Select all
change = {
      era_l = { name="Empire Era", icon2="exGCW_icon" },
      era_1 = { name="Dark Times", icon2="darktimes_icon" }
      }


thank you! I'll try it:thumbs:

Gametoast Staff
User avatar
Posts: 2973
Joined: Sun Feb 26, 2006 7:36 am
Location: USA
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set

Re: added new era, now dark times is messed up

Postby [RDH]Zerted » Tue Sep 08, 2009 4:04 pm

You can't give one map two different names for the same era. There is no way to know which name is supposed to go with which game modes. It would be easiest to use a different era character.

v1.3 Tip: If you need to see what eras and game modes a map uses, double click on its name then check the debug log. The double clicking will print out the map's 'addme table' entries. You will see something like:
Code: Select all
custom_AddMapNew()
custom_printTable():    table: 03CE122C
The key, value is:    era_g    1
The key, value is:    mode_wav_g    1
The key, value is:    isModLevel    1
The key, value is:    bSelected    1
The key is mapluafile, the formated value is:    WAV<A>_<B>
custom_printTable(): Returning
custom_printTable():    table: 03CE6E4C
The key, value is:    key    mode_wav
The key, value is:    subst    wav
The key, value is:    showstr    modename.name.wav
The key, value is:    descstr    modename.description.wav
The key, value is:    icon    mode_icon_wav
custom_printTable(): Returning

If you want to add a new custom era to a map that already has an era or game mode change, then you must merge the two change tables. Don't manually combine them. You don't know which other maps the person has installed and if they change the same map too. Instead, loop through each key/value pair in the tables recursively and combine them. I'm not going to write the code to do this right now. If someone needs it, let me know and I'll do it later. In fact, anyone changing something on an official map should do it this way. Not merging the change table will overwrite any changes from any earlier loaded map and any later loaded map not merging may overwrite your map's changes.

Edit: Oh, one era is the number one and the other is the letter L. Still you shouldn't manually add in the Dark Times changes. Instead, merge the change table.

Major
User avatar
Posts: 505
Joined: Wed Dec 31, 2008 1:54 pm
Location: Pax Empiricae; check WIP

Re: added new era, now dark times is messed up

Postby impspy » Tue Sep 08, 2009 4:13 pm

thanks guys it worked; this can be locked

Jedi
User avatar
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: added new era, now dark times is messed up

Postby Frisbeetarian » Tue Sep 08, 2009 4:18 pm

@Zerted
Well, if merging is the best way to do it, then by all means we need to know how to do it. Yes, we can use the way you described to see visually the keys, but how should we go about accessing those with Lua code?

Gametoast Staff
User avatar
Posts: 2973
Joined: Sun Feb 26, 2006 7:36 am
Location: USA
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set

Re: added new era, now dark times is messed up

Postby [RDH]Zerted » Sat Sep 12, 2009 6:39 pm

Frisbeetarian wrote:...how should we go about accessing those with Lua code?
The info that gets displayed is just one entry from the sp_missionselect_listbox_contents or the mp_missionselect_listbox_contents table. Those tables are a list of tables that contain the displayed key,value pairs.

For everyone adding new game modes to existing maps, you should replace the top section of your addme.lua with:
Hidden/Spoiler:
Code: Select all
-- recursively merges the second given table into the first given table
function MergeTables( mission, newFlags )
   --for each table entry,
   local array = type({})
   for key,value in pairs(newFlags) do      
      --check for nested tables
      if type(value) == array then
         --mission must have this key as a table too
         if type(mission[key]) ~= array then
            mission[key] = {}
         end
         --merge these two tables recursively
         MergeTables(mission[key], value)
      else
         --the key is a simple variable, so simply store it
         mission[key] = value
      end
   end
end

--Search through the missionlist to find a map that matches mapName,
--then insert the new flags into said entry.
--Use this when you know the map already exists, but this content patch is just
--adding new gamemodes (otherwise you should just add whole new entries to the missionlist)
function AddNewGameModes(missionList, mapName, newFlags)
   for i, mission in missionList do
      if mission.mapluafile == mapName then
         MergeTables(mission, newFlags)
      end
   end
end

--insert totally new maps here:

Return to SWBF2 Modding

Who is online

Users browsing this forum: No registered users and 1 guest