Page 1 of 1

Making eras (not) show up problem [solved]

Posted: Mon Jan 04, 2010 12:42 pm
by TK432
Hey I'm trying to make eras not show up when you don't have them installed. I'm refering from this topic and came up with a munging error:

http://www.gametoast.com/forums/viewtop ... 98#p272398

What do i have to add instead of "Convofile" when the era is BFX or DT?
Hidden/Spoiler:
I mean this part
[code]if ScriptCB_IsFileExist(Convofile) == 0 then
print("Cannot find "..Convofile or "[Oops, what file?]"..". Skipping PTC's extra missions")
else
print("Found "..Convofile..". Adding PTC's extra missions")[/code]
Is the rest of the script right?
Hidden/Spoiler:
sp_missionselect_listbox_contents[sp_n+1].era_a = 1 --adds the a era checkbox
sp_missionselect_listbox_contents[sp_n+1].mode_con_a = 1 --adds the con mode checkbox
mp_missionselect_listbox_contents[mp_n+1] = sp_missionselect_listbox_contents[sp_n+1]

AddDownloadableContent("ATC","ATCa_con",4)
This is with BFX's clone area.

Can i make multiple of these (the gcw) or do i have to attend for something?

Thanks in advance

Re: Making eras (not) show up problem

Posted: Mon Jan 04, 2010 8:07 pm
by Maveritchell
"Convofile" is just an arbitrary variable. To be able to tell whether it's correct or not we'd have to see more of your script; the section with the IsFileExist checks should look a bit like this:

Code: Select all

if ScriptCB_IsFileExist(kotorfile) == 0 then
   print("Cannot find "..kotorfile..".  Skipping BRO's extra KotOR missions")
else
   print("Found "..kotorfile..".  Adding BRO's extra KotOR missions")

   sp_missionselect_listbox_contents[sp_n+1].era_k = 1    --adds the k era checkbox
   sp_missionselect_listbox_contents[sp_n+1].mode_con_k = 1    --adds the con mode checkbox
   sp_missionselect_listbox_contents[sp_n+1].mode_tdm_k = 1    --adds the con mode checkbox
   mp_missionselect_listbox_contents[mp_n+1] = sp_missionselect_listbox_contents[sp_n+1]

   AddDownloadableContent("BRO","BROk_con",4)
   AddDownloadableContent("BRO","BROk_tdm",4)
end

if ScriptCB_IsFileExist(dtfile) == 0 then
   print("Cannot find "..dtfile..".  Skipping BRO's extra Dark Times missions")
else
   print("Found "..dtfile..".  Adding BRO's extra Dark Times missions")
   
   ReadDataFile("..\\..\\addon\\BDT\\data\\_LVL_PC\\dtshell.lvl")

   sp_missionselect_listbox_contents[sp_n+1].era_1 = 1    --adds the k era checkbox
   sp_missionselect_listbox_contents[sp_n+1].mode_con_1 = 1    --adds the con mode checkbox
   sp_missionselect_listbox_contents[sp_n+1].change = {
		era_1 = { name="Dark Times", icon2="darktimes_icon" },
		}   --adds the icon?
   mp_missionselect_listbox_contents[mp_n+1] = sp_missionselect_listbox_contents[sp_n+1]

   AddDownloadableContent("BRO","BRO1_con",4)
      
end

Re: Making eras (not) show up problem

Posted: Mon Jan 04, 2010 8:13 pm
by TK432
like this (for bfx cw)?
Hidden/Spoiler:
if ScriptCB_IsFileExist(bfxfile) == 0 then
print("Cannot find "..bfxfile..". Skipping BFX's extra missions")
else
print("Found "..bfxfile..". Adding BFX's missions")

sp_missionselect_listbox_contents[sp_n+1].era_a = 1 --adds the a era checkbox
sp_missionselect_listbox_contents[sp_n+1].mode_con_a = 1 --adds the con mode checkbox
mp_missionselect_listbox_contents[mp_n+1] = sp_missionselect_listbox_contents[sp_n+1]

AddDownloadableContent("ATC","ATCa_con",4)
Edit: still getting the error at this point

Re: Making eras (not) show up problem

Posted: Mon Jan 04, 2010 8:41 pm
by Maveritchell
Post your whole addme.lua and the error you're getting as well.

If what you posted is your whole IsFileExist section then you are missing an "end" statement.

Re: Making eras (not) show up problem

Posted: Mon Jan 04, 2010 8:42 pm
by [RDH]Zerted
You're missing the top of the script where the file variable is defined: local Convofile = "side\\rvs.lvl"

You will need to change the file to be whatever file the mod you want adds to the game.

Re: Making eras (not) show up problem

Posted: Mon Jan 04, 2010 8:52 pm
by TK432
I'm using multiple sides, how would i set up this then?
the sides are all in SIDE//BFX
shall i just add the path or list all the sides??

heres the whole part i added till the end of the script as far as i have it
Hidden/Spoiler:
if ScriptCB_IsFileExist(bfxfile) == 0 then
print("Cannot find "..bfxfile..". Skipping BFX's extra missions")
else
print("Found "..bfxfile..". Adding BFX's missions")

sp_missionselect_listbox_contents[sp_n+1].era_a = 1 --adds the a era checkbox
sp_missionselect_listbox_contents[sp_n+1].mode_con_a = 1 --adds the con mode checkbox
mp_missionselect_listbox_contents[mp_n+1] = sp_missionselect_listbox_contents[sp_n+1]

AddDownloadableContent("ATC","ATCa_con",4)

end

-- all done
newEntry = nil
n = nil

-- Now load our core.lvl into the shell to add our localize keys
ReadDataFile("..\\..\\addon\\ACT\\data\\_LVL_PC\\core.lvl")
do i have to add the definition right over it?

Re: Making eras (not) show up problem

Posted: Mon Jan 04, 2010 9:30 pm
by Maveritchell
Maveritchell wrote:Post your whole addme.lua and the error you're getting as well.

Re: Making eras (not) show up problem

Posted: Tue Jan 05, 2010 8:05 am
by TK432
here we go, sorry
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


ReadDataFile("..\\..\\addon\\BDT\\data\\_LVL_PC\\dtshell.lvl")


--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 = "ACT%s_%s", era_b = 1, era_a = 1, era_1 = 1, era_g = 1, era_c = 1, mode_con_b = 1, mode_con_a = 1, mode_con_1 = 1, mode_con_g = 1, mode_con_c = 1,}
change = {
era_1 = { name="Dark Times", icon2="darktimes_icon" },
}
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("ACT","ACTg_con",4)
AddDownloadableContent("ACT","ACTc_con",4)
AddDownloadableContent("ACT","ACT1_con",4)
AddDownloadableContent("ATC","ATCb_con",4)

if ScriptCB_IsFileExist(bfxfile) == 0 then
print("Cannot find "..bfxfile..". Skipping BFX's extra missions")
else
print("Found "..bfxfile..". Adding BFX's missions")

sp_missionselect_listbox_contents[sp_n+1].era_a = 1 --adds the a era checkbox
sp_missionselect_listbox_contents[sp_n+1].mode_con_a = 1 --adds the con mode checkbox
mp_missionselect_listbox_contents[mp_n+1] = sp_missionselect_listbox_contents[sp_n+1]

AddDownloadableContent("ATC","ATCa_con",4)

end

-- all done
newEntry = nil
n = nil

-- Now load our core.lvl into the shell to add our localize keys
ReadDataFile("..\\..\\addon\\ACT\\data\\_LVL_PC\\core.lvl")
the error seems to be gone after another munge, but the era still doesn't disappear after taking BFX away.

Re: Making eras (not) show up problem

Posted: Tue Jan 05, 2010 1:54 pm
by Maveritchell
Like Zerted said above, you're missing a definition for your file variable. You have to pick a file from the mod you're loading (in this case, from the "BFX" folder would be ideal). It would look something like this, and should be defined above your "if" statement:

Code: Select all

local dtfile = "..\\..\\addon\\BDT\\data\\_LVL_PC\\SIDE\\dark.lvl"
In this case, for the Dark Times mod I picked "dark.lvl;" you can see how it's loaded directly from "BDT"s side folder. The file you pick is irrelevant as long as it is a file that is only there when the mod is installed.

Re: Making eras (not) show up problem

Posted: Tue Jan 05, 2010 4:12 pm
by TK432
hows that?
Hidden/Spoiler:
local bfxfile = "..\\..\\data\\_LVL_PC\\SIDE\\BFXsides\\212.lvl"

if ScriptCB_IsFileExist(bfxfile) == 0 then
print("Cannot find "..bfxfile..". Skipping BFX's extra missions")
else
print("Found "..bfxfile..". Adding BFX's missions")

sp_missionselect_listbox_contents[sp_n+1].era_a = 1 --adds the a era checkbox
sp_missionselect_listbox_contents[sp_n+1].mode_con_a = 1 --adds the con mode checkbox
mp_missionselect_listbox_contents[mp_n+1] = sp_missionselect_listbox_contents[sp_n+1]

AddDownloadableContent("ATC","ATCa_con",4)

end

-- all done
newEntry = nil
n = nil

-- Now load our core.lvl into the shell to add our localize keys
ReadDataFile("..\\..\\addon\\ACT\\data\\_LVL_PC\\core.lvl")
The BFX sides were installed in the actual game folder and not in its addon

trying it out now

Re: Making eras (not) show up problem

Posted: Tue Jan 05, 2010 5:01 pm
by Maveritchell
TK432 wrote:hows that?
Hidden/Spoiler:
local bfxfile = "..\\..\\data\\_LVL_PC\\SIDE\\BFXsides\\212.lvl"
That should be fine, but you could just abbreviate that to:

Code: Select all

local bfxfile = "side\\212.lvl"
When you're reading a directory through a script, you'll use a double backslash instead of a single backslash, as seen above (\\), as a separator. The double period (..) is shorthand for "move up in the directory" and the default directory being read in an addme.lua is "GameData\Data\_LVL_PC" - so in this case you have some unnecessary instruction.

The default directory in any addon mod is "addon\MODID\data\_LVL_PC", which is why I could pack everything into an addon folder for Dark Times and still let you read it through a separate addon folder's mission scripts.

In any case I don't see a problem with what you have up there, this is just for your information.

Re: Making eras (not) show up problem

Posted: Wed Jan 06, 2010 10:35 am
by TK432
i corrected the path to the short form you suggested, but the era still appears in the game, there seems to be missing something.
heres my addme again
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


ReadDataFile("..\\..\\addon\\BDT\\data\\_LVL_PC\\dtshell.lvl")


--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 = "ACT%s_%s", era_b = 1, era_a = 1, era_1 = 1, era_g = 1, era_c = 1, mode_con_b = 1, mode_con_a = 1, mode_con_1 = 1, mode_con_g = 1, mode_con_c = 1,}
change = {
era_1 = { name="Dark Times", icon2="darktimes_icon" },
}
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("ACT","ACTg_con",4)
AddDownloadableContent("ACT","ACTc_con",4)
AddDownloadableContent("ACT","ACT1_con",4)
AddDownloadableContent("ATC","ATCb_con",4)

local bfxfile = "side\\BFXsides\\212.lvl"

if ScriptCB_IsFileExist(bfxfile) == 0 then
print("Cannot find "..bfxfile..". Skipping BFX's extra missions")
else
print("Found "..bfxfile..". Adding BFX's missions")

sp_missionselect_listbox_contents[sp_n+1].era_a = 1 --adds the a era checkbox
sp_missionselect_listbox_contents[sp_n+1].mode_con_a = 1 --adds the con mode checkbox
mp_missionselect_listbox_contents[mp_n+1] = sp_missionselect_listbox_contents[sp_n+1]

AddDownloadableContent("ATC","ATCa_con",4)

end

-- all done
newEntry = nil
n = nil

-- Now load our core.lvl into the shell to add our localize keys
ReadDataFile("..\\..\\addon\\ACT\\data\\_LVL_PC\\core.lvl")
could it be that its because i didn't "hide" BFX's gcw era yet?

Re: Making eras (not) show up problem

Posted: Tue Jan 12, 2010 4:08 pm
by Maveritchell
TK432 wrote:could it be that its because i didn't "hide" BFX's gcw era yet?
Your Battlefront Extreme mission is only going to disappear from the selection screen once this file (side\\BFXsides\\212.lvl) is no longer in that location. It might be best to have your file check be for something in your Battlefront Extreme addon folder so that whenever the addon folder is moved it is not visible.

Re: Making eras (not) show up problem [solved]

Posted: Tue Jan 12, 2010 4:33 pm
by TK432
it's working now, thanks a lot mav' for helping me out.