Page 1 of 1

Addme.lua modification for a mod [Solved]

Posted: Mon Jun 16, 2014 8:13 am
by Indytotof
Hello modders and mappers, here is Indytotof !

I'm creating a new mod that add the Clone Wars era on Endor and Hoth, the Galatic Civil War on Geonosis and Assault mod on Coruscant, Mustafar, Kamino and Naboo copying the Campaign mod (Clone VS Jedi on Coruscant, Empire VS CIS on Mustafar, Empire VS Republic on Kamino and Empire VS Naboo rebels on Naboo).

Here is the addme.lua script:
Hidden/Spoiler:
--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_c = 1, mode_eli_c = 1,})

AddNewGameModes(sp_missionselect_listbox_contents,
"cor1s%_%s",
{era_c = 1, mode_eli_c = 1,})

AddNewGameModes(sp_missionselect_listbox_contents,
"end1%s_%s",
{era_c = 1, mode_con_c = 1, mode_1flag_c = 1,})

AddNewGameModes(sp_missionselect_listbox_contents,
"end1%s_%s",
{era_c = 1, mode_con_c = 1, mode_1flag_c = 1,})

AddNewGameModes(sp_missionselect_listbox_contents,
"geo1%s_%s",
{era_g = 1, mode_con_g = 1, mode_ctf_g = 1, mode_xl_g = 1,})

AddNewGameModes(sp_missionselect_listbox_contents,
"geo1%s_%s",
{era_g = 1, mode_con_g = 1, mode_ctf_g = 1,})

AddNewGameModes(sp_missionselect_listbox_contents,
"hot1%s_%s",
{era_c = 1, mode_con_c = 1, mode_1flag_c = 1, mode_1flag_c = 1, mode_xl_c = 1,})

AddNewGameModes(sp_missionselect_listbox_contents,
"hot1%s_%s",
{era_c = 1, mode_con_c = 1, mode_1flag_c = 1, mode_xl_c = 1,})

AddNewGameModes(sp_missionselect_listbox_contents,
"hot1%s_%s",
{era_c = 1, mode_con_c = 1, mode_1flag_c = 1,})

AddNewGameModes(sp_missionselect_listbox_contents,
"kam1%2_%2",
{era_c = 1, mode_eli_c = 1,})

AddNewGameModes(sp_missionselect_listbox_contents,
"kam1%2_%2",
{era_c = 1, mode_eli_c =1,})

AddNewGameModes(sp_missionselect_listbox_contents,
"mus1%s_%s",
{era_c = 1, mode_eli_c = 1,})

AddNewGameModes(sp_missionselect_listbox_contents,
"mus1%s_%s",
{era_c = 1, mode_eli_c = 1,})

AddNewGameModes(sp_missionselect_listbox_contents,
"nab2%s_%s",
{era_g = 1, mode_eli_g = 1,})

AddNewGameModes(sp_missionselect_listbox_contents,
"nab2%s_%s"
{era_g = 1, mode_eli_g = 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("COR1","cor1c_eli",4)
AddDownloadableContent("END1","end1c_1flag",4)
AddDownloadableContent("END1","end1c_con",4)
AddDownloadableContent("GEO1","geo1g_con",4)
AddDownloadableContent("GEO1","geo1g_ctf",4)
AddDownloadableContent("GEO1","geo1g_xl",4)
AddDownloadableContent("HOT1","hot1c_1flag",4)
AddDownloadableContent("HOT1",'hot1c_con",4)
AddDownloadableContent("HOT1","hot1c_xl",4)
AddDownloadableContent("KAM1","kam1c_eli",4)
AddDownloadableContent("MUS1","mus1c_eli",4)
AddDownloadableContent("NAB2","nab2g_eli",4)


-- all done
newEntry = nil
n = nil

-- Now load our core.lvl into the shell to add our localize keys
ReadDataFile("..\\..\\addon\\TES\\data\\_LVL_PC\\core.lvl")
Did I do all right ? did I can munge my addme ?

Thanks for your advice !

Re: Addme.lua modification for a mod

Posted: Mon Jun 16, 2014 9:11 am
by DrDrSheldonLeeCooper
I think you make a custom era , right?
Hidden/Spoiler:
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:
local sp_n = 0
local mp_n = 0
sp_n = table.getn(sp_missionselect_listbox_contents)

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)

AddNewGameModes( sp_missionselect_listbox_contents, "myg1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})

AddNewGameModes( mp_missionselect_listbox_contents, "myg1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})




AddNewGameModes( sp_missionselect_listbox_contents, "cor1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})

AddNewGameModes( mp_missionselect_listbox_contents, "cor1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})




AddNewGameModes( sp_missionselect_listbox_contents, "dea1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})

AddNewGameModes( mp_missionselect_listbox_contents, "dea1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})




AddNewGameModes( sp_missionselect_listbox_contents, "mus1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})

AddNewGameModes( mp_missionselect_listbox_contents, "mus1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})




AddNewGameModes( sp_missionselect_listbox_contents, "tan1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})

AddNewGameModes( mp_missionselect_listbox_contents, "tan1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})




AddNewGameModes( sp_missionselect_listbox_contents, "tat2%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})
AddNewGameModes( mp_missionselect_listbox_contents, "tat2%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})




AddNewGameModes( sp_missionselect_listbox_contents, "uta1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})

AddNewGameModes( mp_missionselect_listbox_contents, "uta1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})




AddNewGameModes( sp_missionselect_listbox_contents, "geo1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})

AddNewGameModes( mp_missionselect_listbox_contents, "geo1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})




AddNewGameModes( sp_missionselect_listbox_contents, "tan1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})

AddNewGameModes( mp_missionselect_listbox_contents, "tan1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})




AddNewGameModes( sp_missionselect_listbox_contents, "kam1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})

AddNewGameModes( mp_missionselect_listbox_contents, "kam1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})




AddNewGameModes( sp_missionselect_listbox_contents, "kas2%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})

AddNewGameModes( mp_missionselect_listbox_contents, "kas2%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})




AddNewGameModes( sp_missionselect_listbox_contents, "nab2%s_%s", {era_z = 1, mode_con_z = 1, change = { era_p = { name="After Order 66", icon2="mode_icon_wea" }, }})

AddNewGameModes( mp_missionselect_listbox_contents, "nab2%s_%s", {era_z = 1, mode_con_z = 1, change = { era_p = { name="After Order 66", icon2="mode_icon_wea" }, }})




AddNewGameModes( sp_missionselect_listbox_contents, "fel1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})

AddNewGameModes( mp_missionselect_listbox_contents, "fel1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})




AddNewGameModes( sp_missionselect_listbox_contents, "yav1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})

AddNewGameModes( mp_missionselect_listbox_contents, "yav1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})




AddNewGameModes( sp_missionselect_listbox_contents, "yav2%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})

AddNewGameModes( mp_missionselect_listbox_contents, "yav2%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})




AddNewGameModes( sp_missionselect_listbox_contents, "hot1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})

AddNewGameModes( mp_missionselect_listbox_contents, "hot1%s_%s", {era_z = 1, mode_con_z = 1, change = { era_z = { name="After Order 66", icon2="mode_icon_wea" }, }})

AddDownloadableContent("myg1","myg1z_con",4)
AddDownloadableContent("cor1","cor1z_con",4)
AddDownloadableContent("dea1","dea1z_con",4)
AddDownloadableContent("mus1","mus1z_con",4)
AddDownloadableContent("tan1","tan1z_con",4)
AddDownloadableContent("tat2","tat2z_con",4)
AddDownloadableContent("uta1","uta1z_con",4)
AddDownloadableContent("geo1","geo1z_con",4)
AddDownloadableContent("nab2","nab2z_con",4)
AddDownloadableContent("kas2","kas2z_con",4)
AddDownloadableContent("tan1","tan1z_con",4)
AddDownloadableContent("yav2","yav2z_con",4)
AddDownloadableContent("yav1","yav1z_con",4)
AddDownloadableContent("kam1","kam1z_con",4)
AddDownloadableContent("fel1","fel1z_con",4)
AddDownloadableContent("hot1","hot1z_con",4)

-- all done
newEntry = nil
n = nil

-- Now load our core.lvl into the shell to add our localize keys
ReadDataFile("..\\..\\addon\\TES\\data\\_LVL_PC\\core.lvl")
After Order 66 is the era name,but you can change it.

"z" means that this is a custom era (I think)

for example,you wish to make hoth with clones,then you go to assets\scripts\hot then you COPY hot1g_con ("g" is galactic zivil war) and put it in C:\BF2_ModTools\data_TES\Common\scripts\TES (TES is your mod right?)
and rename it to hot1z_con,then you go to C:\BF2_ModTools\data_TES\Common and open mission.req then you write hot1z_con in it, for example :
Hidden/Spoiler:
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"
"MELg_con"
"MELc_con"
"cor1z_con"
"geo1z_con"
"kas2z_con"
"tat2z_con"
"myg1z_con"
"dea1z_con"
}
}
this is my mission req.

then you go to C:\BF2_ModTools\data_TES\Common\mission and COPY hot1g_con and rename it to hot1z_con, then open hot1z_con.req and you see there is this :
Hidden/Spoiler:
ucft
{
REQN
{
"script"
"hot1g_con"
}
}
I made hot1g_con in red because this is the line which you delete and put hot1z_con in it.


Hope that can help you,and you have to put the "z" just if you use my addme.sry for my bad english.

Did you know how to add clones to Hoth?If not , ask me.

Re: Addme.lua modification for a mod

Posted: Mon Jun 16, 2014 9:47 am
by Indytotof
I'm currently using the + 123 mod (all his sources are avaible for download) as my mod's base because there is all I need to proceed, but I will changed some things, like make the jedis, the temple guard, the naboo guards and the droids on Mustafar appears as the Rebel Alliance and the CIS respectivly (and I think here I'll need help because it's a lot more difficult).

I know how to add clones or other basics sides (Empire, Alliance, CIS and Republic), it's not that difficult.

I onlt need a confirmation if I doing right the addme.lua modification for munging it as a addme.script.

Thanks for your answer though.

Re: Addme.lua modification for a mod

Posted: Mon Jun 16, 2014 9:53 am
by DrDrSheldonLeeCooper
I think it´s right,make a BackUp then munge and test it.

Re: Addme.lua modification for a mod

Posted: Mon Jun 16, 2014 10:04 am
by Indytotof
DrDrSheldonLeeCooper wrote:I think it´s right,make a BackUp then munge and test it.
I'll have do a backup but.... I'll wait some other answer, I'm not so sure (either I look up the addme.lua from the +123 when I've doing mine).

Thanks though.

EDIT: There is a problem. That's the log of my addme munging:
Hidden/Spoiler:
Logging ScriptMunge
16:05:1206/16/14
ERROR[addme.lua]:Could not read input file.ERROR[addme.lua]:Could not read input file. [continuing]
2 Errors 0 Warnings
What i've exaclty do wrong ?

Re: Addme.lua modification for a mod

Posted: Mon Jun 16, 2014 10:44 am
by DrDrSheldonLeeCooper
your addme end :

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

is "TES" the name of your data_*** folder?

Re: Addme.lua modification for a mod

Posted: Mon Jun 16, 2014 10:47 am
by Indytotof
NO, it's BF2.

Re: Addme.lua modification for a mod

Posted: Mon Jun 16, 2014 10:48 am
by DrDrSheldonLeeCooper
Then change the "TES" on the end of the addme to BF2

Re: Addme.lua modification for a mod

Posted: Mon Jun 16, 2014 10:53 am
by Indytotof
Oopsy...

EDIT:
Hidden/Spoiler:
Logging ScriptMunge
16:53:1906/16/14
ERROR[addme.lua]:Could not read input file.ERROR[addme.lua]:Could not read input file. [continuing]
2 Errors 0 Warnings
Same problem....

Re: Addme.lua modification for a mod

Posted: Mon Jun 16, 2014 11:02 am
by DrDrSheldonLeeCooper
send me your new addme pls

Re: Addme.lua modification for a mod

Posted: Mon Jun 16, 2014 11:13 am
by Indytotof
DrDrSheldonLeeCooper wrote:send me your new addme pls

Here there are:
Hidden/Spoiler:

Re: Addme.lua modification for a mod

Posted: Mon Jun 16, 2014 11:22 am
by DrDrSheldonLeeCooper
Hidden/Spoiler:
AddDownloadableContent("COR1","cor1c_eli",4)
AddDownloadableContent("END1","end1c_1flag",4)
AddDownloadableContent("END1","end1c_con",4)
AddDownloadableContent("GEO1","geo1g_con",4)
AddDownloadableContent("GEO1","geo1g_ctf",4)
AddDownloadableContent("GEO1","geo1g_xl",4)
AddDownloadableContent("HOT1","hot1c_1flag",4)
AddDownloadableContent("HOT1",'hot1c_con",4)
AddDownloadableContent("HOT1","hot1c_xl",4)
AddDownloadableContent("KAM1","kam1c_eli",4)
AddDownloadableContent("MUS1","mus1c_eli",4)
AddDownloadableContent("NAB2","nab2g_eli",4)
Hidden/Spoiler:
AddNewGameModes(sp_missionselect_listbox_contents,
"hot1%s_%s",
{era_c = 1, mode_con_c = 1, mode_1flag_c = 1,})
You are loading hot1c_con,but Hoth has no clone wars ,c=clone wars, you have to take hot1g_con and change the Units.

Re: Addme.lua modification for a mod

Posted: Mon Jun 16, 2014 11:28 am
by Indytotof
Since I use the +123 mod as base, Hoth have a Clone Wars era, as for Endor.

Re: Addme.lua modification for a mod

Posted: Mon Jun 16, 2014 11:34 am
by DrDrSheldonLeeCooper
Hm, I don't know why it's crashing,is 123 mod easier for you?

Re: Addme.lua modification for a mod

Posted: Mon Jun 16, 2014 11:39 am
by Indytotof
DrDrSheldonLeeCooper wrote:Hm, I don't know why it's crashing,is 123 mod easier for you?
A lot. Since all I need is here. But not like I wished. That's why I want to make a mod using the +123 mod as base. The only thing I want to do is put a 1Flag anf Assault mod on Space Coruscant (unlocked using the v1.3 patch) and Space Mustafar (unlocked the same way than Space Coruscant). But I don't really know how. For that matter, I've to read the v1.3 patch documentation.