Trouble with addme.lua for multiple maps [Solved]

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
ZoomV
Rebel Warrant Officer
Rebel Warrant Officer
Posts: 308
Joined: Thu Aug 15, 2013 11:27 am
Projects :: Old Republic Map pack
Games I'm Playing :: BF2 SWTOR and GW2
xbox live or psn: No gamertag set
Location: Belsavis, Maximum Security Ward

Trouble with addme.lua for multiple maps [Solved]

Post by ZoomV »

So I'm trying to run three maps from one directory. I already have two of them working from the directory, but the third won't work.
addme.lua
(BVS and ACW are the ones that work, MAK is the one that does not.)
Hidden/Spoiler:
[code]--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 totally new maps here:
local sp_n = 0
local mp_n = 0
sp_n = table.getn(sp_missionselect_listbox_contents)

sp_missionselect_listbox_contents[sp_n+1] = {
isModLevel = 1,
mapluafile = "BVS%s_%s",
era_g = 1,
mode_con_g = 1,
change ={
era_g = { name="Second Galactic War" },
},
}
mp_n = table.getn(mp_missionselect_listbox_contents)
mp_missionselect_listbox_contents[mp_n+1] = sp_missionselect_listbox_contents[sp_n+1]

sp_n = table.getn(sp_missionselect_listbox_contents)
sp_missionselect_listbox_contents[sp_n+1] = {
isModLevel = 1,
mapluafile = "MAK%s_%s",
era_g = 1,
mode_con_g = 1,
mode_1flag_g = 1,
change ={
era_g = { name="Second Galactic War" },
},
}
mp_n = table.getn(mp_missionselect_listbox_contents)
mp_missionselect_listbox_contents[mp_n+1] = sp_missionselect_listbox_contents[sp_n+1]

sp_n = table.getn(sp_missionselect_listbox_contents)
sp_missionselect_listbox_contents[sp_n+1] = {
isModLevel = 1,
mapluafile = "ACW%s_%s",
era_g = 1,
mode_con_g = 1,
change ={
era_g = { name="Great Galactic War" },
},
}
mp_n = table.getn(mp_missionselect_listbox_contents)
mp_missionselect_listbox_contents[mp_n+1] = sp_missionselect_listbox_contents[sp_n+1]

-- 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("ACW","ACWg_con",4)
AddDownloadableContent("BVS","BVSg_con",4)
AddDownloadableContent("MAK","MAKg_con",4)
AddDownloadableContent("MAK","MAKg_1flag",4)

-- all done
newEntry = nil
n = nil

-- Now load our core.lvl into the shell to add our localize keys
ReadDataFile("..\\..\\addon\\TOR\\data\\_LVL_PC\\core.lvl")
[/code]
mission.req
Hidden/Spoiler:
[code]ucft
{
REQN
{
"config"
"ingame_movies"
}

REQN
{
"script"
"setup_teams"
"gametype_conquest"
"gametype_capture"
"Objective"
"MultiObjectiveContainer"
"ObjectiveCTF"
"ObjectiveAssault"
"ObjectiveSpaceAssault"
"ObjectiveConquest"
"ObjectiveTDM"
"ObjectiveOneFlagCTF"
"SoundEvent_ctf"
"ObjectiveGoto"
"LinkedShields"
"LinkedDestroyables"
"LinkedTurrets"
"Ambush"
"PlayMovieWithTransition"
}

REQN
{
"lvl"
"ACWg_con"
"BVSg_con"
"MAKg_con"
"MAKg_1flag"
}
}[/code]
MAKg_1flag.req
Hidden/Spoiler:
[code]ucft
{
REQN
{
"script"
"MAKg_1flag"
}
}
[/code]
MAKg_con.req
Hidden/Spoiler:
[code]ucft
{
REQN
{

"config"
"cor_movies"

}

REQN
{
"script"
"MAKg_con"
}
}
[/code]
Last edited by ZoomV on Wed Mar 18, 2015 3:19 pm, edited 1 time in total.
jedimoose32
Field Commander
Field Commander
Posts: 938
Joined: Thu Jan 24, 2008 12:41 am
Projects :: Engineering Degree
Location: The Flatlands of Canada

Re: trouble with addme.lua for multiple maps

Post by jedimoose32 »

I don't see anything immediately wrong with your addme.
Maybe try adding the config section to your MAKg_1flag.req? I know some of the stock .reqs don't include it but every default MODera_mode.req I've seen has included it. I've honestly yet to see one without it, for any of my maps, no matter how few or how many eras and modes.

In what way does the MAK map not work? Does it not show up at all in the map selection screen? Does it crash the game when you play it?
ZoomV
Rebel Warrant Officer
Rebel Warrant Officer
Posts: 308
Joined: Thu Aug 15, 2013 11:27 am
Projects :: Old Republic Map pack
Games I'm Playing :: BF2 SWTOR and GW2
xbox live or psn: No gamertag set
Location: Belsavis, Maximum Security Ward

Re: trouble with addme.lua for multiple maps

Post by ZoomV »

It doesn't show up on map selection
jedimoose32
Field Commander
Field Commander
Posts: 938
Joined: Thu Jan 24, 2008 12:41 am
Projects :: Engineering Degree
Location: The Flatlands of Canada

Re: trouble with addme.lua for multiple maps

Post by jedimoose32 »

Replace everything before "--insert totally new maps here" with this code:
Hidden/Spoiler:
[code]
-- 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
[/code]
ZoomV
Rebel Warrant Officer
Rebel Warrant Officer
Posts: 308
Joined: Thu Aug 15, 2013 11:27 am
Projects :: Old Republic Map pack
Games I'm Playing :: BF2 SWTOR and GW2
xbox live or psn: No gamertag set
Location: Belsavis, Maximum Security Ward

Re: trouble with addme.lua for multiple maps

Post by ZoomV »

nope still not working
jedimoose32
Field Commander
Field Commander
Posts: 938
Joined: Thu Jan 24, 2008 12:41 am
Projects :: Engineering Degree
Location: The Flatlands of Canada

Re: trouble with addme.lua for multiple maps

Post by jedimoose32 »

Weird. I'm at a loss for now. The only thing I can think of, which is a shot in the dark anyway, is to try playing with the order of the maps as they're loaded in add me and in mission. I'm pretty OCD when it comes to making sure things are in the right order, so personally I would try A. Alphabetizing the order of the maps and modes in add me, and B. Changing their order in mission.req to the same order as in addme. Again it might not work but it's something I would try.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: trouble with addme.lua for multiple maps

Post by [RDH]Zerted »

Your code seems fine... You don't directly increment sp_n or mp_n, but you reset them after each time you add a map so that's fine. But I'd recommend printing out sp_n and mp_n after you get them. They should increment by 1 each time. If nothing prints out then you're not running what you think you're running (always a possibility).

Next remove all the other mod maps. One of them might be clobbering your entries. The code jedimoose32 posted prevents you from accidentally clobbering someone else's map, so make sure to always use it from now on.

Does the map not show up in both SP and MP selection lists? Is the map there but not your mission or is the map completely missing? If the map is there you can double-click on it and v1.3 will print out the table details to the debug log. Post that if you can get it.
ZoomV
Rebel Warrant Officer
Rebel Warrant Officer
Posts: 308
Joined: Thu Aug 15, 2013 11:27 am
Projects :: Old Republic Map pack
Games I'm Playing :: BF2 SWTOR and GW2
xbox live or psn: No gamertag set
Location: Belsavis, Maximum Security Ward

Re: trouble with addme.lua for multiple maps [solved]

Post by ZoomV »

Actually guys the addme was working fine, the munge just wasn't copying it over.
Post Reply