Reads sub lvl file (cor1c_con) from the stock mission.lvl, since that is where the mission script is loaded. Second I use ScriptCB_DoFile() to execute that script.
Re: Random Crazy Lua Question
Posted: Fri May 02, 2014 11:11 pm
by commanderawesome
Nedarb7 wrote:For example if I want to use the coruscant (conquest) script I would use this code:
Reads sub lvl file (cor1c_con) from the stock mission.lvl, since that is where the mission script is loaded. Second I use ScriptCB_DoFile() to execute that script.
Sweet! Thanks!
EDIT
Do you add this to a blank script?
And can this be done with other mod maps?
EDIT
I still need help with this.
Re: Random Crazy Lua Question (Help still needed)
Posted: Mon May 26, 2014 4:19 pm
by Nedarb7
Yes and yes. The code I gave you would be the entire script. To get a different mod's mission script you'd change the path to something like this:
(I tried the map it calls for, it runs how it's supposed to.)
Still Crashes, now as soon as I press "Launch". Is that code supposed to be before or after ScriptCB_DoFile("UOAc_Diet Dr. Pepper")?
Huh. Maybe it can't handle that much data all at once. For now comment those lines out or get rid of them completely. The cause of the first crash was probably the fact that it couldn't load the republic side at all. Did you make any side replacements or anything that could screw it up... is the rep.lvl actually in the stock game's side folder?
Without a side a map will crash, while a map without a map will not crash.
(We can deal with the map after you get the sides working. Also could you post what the LUA looked like when it loaded the map and sky?)
Re: Random Crazy Lua Question (Help still needed)
Posted: Mon May 26, 2014 10:09 pm
by commanderawesome
Nedarb7 wrote:Huh. Maybe it can't handle that much data all at once. For now comment those lines out or get rid of them completely. The cause of the first crash was probably the fact that it couldn't load the republic side at all. Did you make any side replacements or anything that could screw it up... is the rep.lvl actually in the stock game's side folder?
Without a side a map will crash, while a map without a map will not crash.
(We can deal with the map after you get the sides working)
The map uses stock and mod units for the republic, cis is stock, both SHOULD be working. Lemme check...
EDIT
Stock Rep works fine. Tried it on stock death star.
Re: Random Crazy Lua Question (Help still needed)
Posted: Tue May 27, 2014 3:17 pm
by Nedarb7
commanderawesome wrote:The map uses stock and mod units for the republic, cis is stock, both SHOULD be working. Lemme check...
Hmmmm... looking back at your first error log I see that it can't find "dc:rep.lvl" and "dc:cis.lvl", it could be that it uses its own stock units if you know what I mean. Like you said, if it is using stock it should be working. I've gotten around the map not loading issue (back to this post), so that shouldn't a problem anymore. If your adding your own units then I'd suggest adding them now, I think it should work with at least one unit per team even if the rest don't load.
(I should also mention that I've gotten it to work on a custom map just today)
Re: Random Crazy Lua Question (Help still needed)
Posted: Tue May 27, 2014 6:34 pm
by commanderawesome
Still crashes...
Mission script:
Hidden/Spoiler:
[code]-- Variables that make the if statements in the setup_teams LUA true
mapCode = 1
-- Read my custom sides
ReadDataFile("dc:SIDE\\rep.lvl",
"rep_inf_ep3_rifleman",
"rep_inf_ep3_sniper",
"rep_inf_ep3_marine")
-- Execute my map's script
ReadDataFile("..\\..\\addon\\UOA\\data\\_LVL_PC\\mission.lvl", "UOAc_Diet Dr. Pepper")
ScriptCB_DoFile("UOAc_Diet Dr. Pepper")
[/code]
setup_teams:
Hidden/Spoiler:
[code]function SetupTeams(sides)
-- HACKish: load the turret .odf here (this is the easiest place to put it where it will
-- be executed in every level
--ReadDataFile("SIDE\\tur.lvl", --disabled for now until we settle on where exactly the .odf will end up
-- "tur_bldg_defensegridturret")
-- Load my map's level file, managed by the mapCode variable in the mission script
if mapCode == 1 then
ReadDataFile("..\\..\\addon\\UOA\\data\\_LVL_PC\\UOA\\UOA.lvl", "uoa_cw-assault")
ReadDataFile("..\\..\\addon\\UOA\\data\\_LVL_PC\\UOA\\spa_sky.lvl")
end
-- list of types
local typeList = { "soldier", "pilot", "assault", "sniper", "marine", "engineer", "officer", "special" }
-- items for each team code
local teamItems = nil
if ScriptCB_IsMissionSetupSaved() then
local missionSetup = ScriptCB_LoadMissionSetup()
teamItems = missionSetup.units
end
-- for each specified side...
for name, side in pairs(sides) do
local team = side.team
-- set team properties
local name = string.lower(name)
SetTeamName(team, name)
SetTeamIcon(team, name .. "_icon", "hud_reinforcement_icon", "flag_icon")
SetUnitCount(team, side.units)
SetReinforcementCount(team, side.reinforcements)
-- add unit classes in type order
for _, type in ipairs(typeList) do
if side[type] and (not teamItems or not teamItems[name] or teamItems[name][type]) then
AddUnitClass(team, side[type][1], side[type][2], side[type][3])
end
end
-- add hero class if available
if side[hero] then
AddHeroClass(side[hero])
end
end[/code]
Log:
Hidden/Spoiler:
[code]Opened logfile BFront2.log 2014-05-27 1728
shell_interface: Entered
shell_interface: gPlatformStr, gOnlineServiceStr, gLangStr, gLangEnum: PC GameSpy english 0
ifs_era_handler - Entered
ifs_era_handler - Exited
shell_interface: No custom_gc_0.lvl
shell_interface: Found custom_gc_1.lvl
custom_gc_1: Entered
ifs_freeform_init_zer.lua
ifs_freeform_start_zer.lua
custom_gc_1: Taking control of custom_GetGCButtonList()...
custom_gc_1: Taking control of custom_PressedGCButton()...
custom_gc_1: Exited
shell_interface: No custom_gc_2.lvl
shell_interface: No custom_gc_3.lvl
shell_interface: No custom_gc_4.lvl
shell_interface: No custom_gc_5.lvl
shell_interface: No custom_gc_6.lvl
shell_interface: No custom_gc_7.lvl
shell_interface: No custom_gc_8.lvl
shell_interface: No custom_gc_9.lvl
shell_interface: Found custom_gc_10.lvl
custom_gc_10: Entered
custom_gc_10: Found custom_gc_11.lvl
custom_gc_11: Entered
ifs_freeform_init_dt.lua
ifs_freeform_start_dt.lua
custom_gc_11: Taking control of custom_GetGCButtonList()...
custom_gc_11: Taking control of custom_PressedGCButton()...
custom_gc_11: Exited
custom_gc_10: No custom_gc_12.lvl. Will stop searching for any more cGC scripts.
custom_gc_10: Exited
custom_EraButtonList(): Finished building era button table Known eras buttons: 28
custom_GetGMapEras(): Finished building era table Known eras: 28
custom_GetGMapModes(): Finished building game mode table Known Modes: 39
custom_GetMPGameModeList(): Finished building game mode list table List Length: 40
custom_SetMovieLocation()
custom_gc_11: custom_GetGCButtonList(): Entered
custom_gc_1: custom_GetGCButtonList(): Entered
custom_GetGCButtonList()
custom_gc_1: custom_GetGCButtonList(): Exited
custom_gc_11: custom_GetGCButtonList(): Exited
custom_SetMovieLocation()
custom_GetFreeformBattleModeList(): Finished building freeform battle mode list Known Modes: 39
ingame stream movies\crawl.mvs
shell_interface: Opening movie: movies\shell.mvs
shell_interface: Leaving
Mission Checker: Entered addme
Mission Checker: addme: Now listening in on AddDownloadableContent() calls
Mission Checker: Exited addme
prev = none iLastPage = nil
prev = texture iLastPage = 1
prev = texture iLastPage = 2
prev = texture iLastPage = 3
ifs_legal.Exit
Message Severity: 2
C:\Battlefront2\main\Battlefront2\Source\GameMovie.cpp(399)
Unable to find open movie segment shell_main
ifs_saveop_DoOps LoadFileList
ifs_saveop_DoOps LoadFileList
ifs_saveop_DoOps LoadProfile
ifs_saveop_DoOps LoadProfile
ifs_sp_campaign: Input_Accept(): Entered: _tab_instant
missionlist_ExpandMapList()
ifs_missionselect_pcMulti_fnSetMapPreview(): Defaulting index to 1
this.CurButton = check_mode4
cur_button = nil
Checkbox for check_era3 clicked
this.CurButton = check_era3
cur_button = nil
custom_AddMapNew()
custom_printTable(): table: 03CE126C
The key, value is: era_c 1
The key, value is: mode_assault_c 1
The key, value is: isModLevel 1
The key, value is: bSelected 1
The key is mapluafile, the formated value is: BOU<A>_<B>
custom_printTable(): Returning
custom_printTable(): table: 03CE6C2C
The key, value is: key mode_assault
The key, value is: subst Diet Dr. Pepper
The key, value is: showstr modename.name.spa-assault
The key, value is: descstr modename.description.assault
The key, value is: icon mode_icon_Diet Dr. Pepper
custom_printTable(): Returning
gMapEras.key = era_c Era = era_c subst = c
Adding map: BOUc_Diet Dr. Pepper idx: 1
this.CurButton = _map_add
cur_button = nil
this.CurButton = Launch
cur_button = nil
Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\Entity.cpp(218)
Entity base class "com_inf_default" not found
[/code]
Re: Random Crazy Lua Question (Help still needed)
Posted: Tue May 27, 2014 8:26 pm
by Marth8880
Are you not loading the stock ingame.lvl or something? That's what that last error is basically saying.
Re: Random Crazy Lua Question (Help still needed)
Posted: Wed May 28, 2014 2:12 pm
by commanderawesome
Marth8880 wrote:Are you not loading the stock ingame.lvl or something? That's what that last error is basically saying.
Hmm... there shouldn't be anything that changed that. Can you PM me a stock one just in case?
Re: Random Crazy Lua Question (Help still needed)
Posted: Wed May 28, 2014 8:19 pm
by Nedarb7
Yet another flaw discovered. Updating the workaround again, I'll edit the post once I finish updating.
Also you have to make sure that you add your units via AddUnitClass as well (also demonstrated in the scenario in setup_teams lua)
- EDIT -
The workaround post has been edited again, hopefully this will be the last. I think you'd only have to look over the setup_teams lua again.
Re: Random Crazy Lua Question (Help still needed)
Posted: Wed May 28, 2014 10:58 pm
by commanderawesome
Nedarb7 wrote:
Also you have to make sure that you add your units via AddUnitClass as well (also demonstrated in the scenario in setup_teams lua)
But i'm replacing units, not adding them...
I'll try that, though...
EDIT
IT WORKS!!!! Sorta. It loads the level, but not stock rep for some reason, cis is fine. And the custom units i'm loading aren't right, but I think it's with the sides themselves. I'll keep ya posted.
Mission lua:
Hidden/Spoiler:
[code]-- Variables that make the if statements in the setup_teams LUA true
mapCode = 1
unitCode = 212
-- Execute my map's script
ReadDataFile("..\\..\\addon\\UOA\\data\\_LVL_PC\\mission.lvl", "UOAc_Diet Dr. Pepper")
ScriptCB_DoFile("UOAc_Diet Dr. Pepper")
[/code]
Setup_teams:
Hidden/Spoiler:
[code]function SetupTeams(sides)
-- HACKish: load the turret .odf here (this is the easiest place to put it where it will
-- be executed in every level
--ReadDataFile("SIDE\\tur.lvl", --disabled for now until we settle on where exactly the .odf will end up
-- "tur_bldg_defensegridturret")
-- Load my map's level file, managed by the mapCode variable in the mission script
if mapCode == 1 then
ReadDataFile("..\\..\\addon\\UOA\\data\\_LVL_PC\\UOA\\UOA.lvl", "uoa_cw-assault")
ReadDataFile("..\\..\\addon\\UOA\\data\\_LVL_PC\\UOA\\spa_sky.lvl")
end
-- list of types
local typeList = { "soldier", "pilot", "assault", "sniper", "marine", "engineer", "officer", "special" }
-- items for each team code
local teamItems = nil
if ScriptCB_IsMissionSetupSaved() then
local missionSetup = ScriptCB_LoadMissionSetup()
teamItems = missionSetup.units
end
-- for each specified side...
for name, side in pairs(sides) do
local team = side.team
-- set team properties
local name = string.lower(name)
SetTeamName(team, name)
SetTeamIcon(team, name .. "_icon", "hud_reinforcement_icon", "flag_icon")
SetUnitCount(team, side.units)
SetReinforcementCount(team, side.reinforcements)
-- add unit classes in type order
for _, type in ipairs(typeList) do
if side[type] and (not teamItems or not teamItems[name] or teamItems[name][type]) then
AddUnitClass(team, side[type][1], side[type][2], side[type][3])
end
end
-- add hero class if available
if side[hero] then
AddHeroClass(side[hero])
end
end
-- Inject Custom Units into mission
-- Variable "unitCode" found in mission lua
if unitCode == 212 then
ReadDataFile("dc:SIDE\\rep.lvl", "rep_inf_ep3_rifleman", "rep_inf_ep3_sniper", "rep_inf_ep3_marine")
ReadDataFile("dc:SIDE\\air.lvl", "rep_inf_ep3_officer", "rep_inf_ep3_jettrooper")
end
end[/code]
EDIT
I forgot that I renamed stock rep . Still dunno what's up with the custom sides, they themselves are fine. And vehicles won't load, for either side!
Re: Random Crazy Lua Question (Help still needed)
Posted: Tue Jun 03, 2014 1:58 pm
by Nedarb7
Your units wont appear unless you use AddUnitClass(), that's what all units use (including stock). I'll test the workaround for removing the stock sides found on that same post.
Re: Random Crazy Lua Question (Help still needed)
Posted: Tue Jun 03, 2014 2:28 pm
by commanderawesome
Nedarb7 wrote:Your units wont appear unless you use AddUnitClass(), that's what all units use (including stock). I'll test the workaround for removing the stock sides found on that same post.
Now it crashes.
Mission script is unmodified from before.
setup_teams:
Hidden/Spoiler:
[code]function SetupTeams(sides)
-- HACKish: load the turret .odf here (this is the easiest place to put it where it will
-- be executed in every level
--ReadDataFile("SIDE\\tur.lvl", --disabled for now until we settle on where exactly the .odf will end up
-- "tur_bldg_defensegridturret")
-- Load my map's level file, managed by the mapCode variable in the mission script
if mapCode == 1 then
ReadDataFile("..\\..\\addon\\UOA\\data\\_LVL_PC\\UOA\\UOA.lvl", "uoa_cw-assault")
ReadDataFile("..\\..\\addon\\UOA\\data\\_LVL_PC\\UOA\\spa_sky.lvl")
end
-- list of types
local typeList = { "soldier", "pilot", "assault", "sniper", "marine", "engineer", "officer", "special" }
-- items for each team code
local teamItems = nil
if ScriptCB_IsMissionSetupSaved() then
local missionSetup = ScriptCB_LoadMissionSetup()
teamItems = missionSetup.units
end
-- for each specified side...
for name, side in pairs(sides) do
local team = side.team
-- set team properties
local name = string.lower(name)
SetTeamName(team, name)
SetTeamIcon(team, name .. "_icon", "hud_reinforcement_icon", "flag_icon")
SetUnitCount(team, side.units)
SetReinforcementCount(team, side.reinforcements)
-- add unit classes in type order
for _, type in ipairs(typeList) do
if side[type] and (not teamItems or not teamItems[name] or teamItems[name][type]) then
AddUnitClass(team, side[type][1], side[type][2], side[type][3])
end
end
-- add hero class if available
if side[hero] then
AddHeroClass(side[hero])
end
end
-- Inject Custom Units into mission
-- Variable "unitCode" found in mission lua
if unitCode == 212 then
ReadDataFile("dc:SIDE\\rep.lvl", "rep_inf_ep3_rocketeer", "rep_inf_ep3_engineer")
ReadDataFile("dc:SIDE\\air.lvl", "rep_inf_ep3_officer", "rep_inf_ep3_jettrooper")
AddUnitClass(REP, "rep_inf_ep3_rocketeer",1,4)
AddUnitClass(REP, "rep_inf_ep3_engineer",1,4)
AddUnitClass(REP, "rep_inf_ep3_officer",1,4)
AddUnitClass(REP, "rep_inf_ep3_jettrooper",1,4)
end
end[/code]