Random Crazy Lua Question (Help still needed)

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
User avatar
commanderawesome
Field Commander
Field Commander
Posts: 970
Joined: Tue Aug 13, 2013 11:58 pm
Projects :: Skin Changer - Warfront - Other stuff
Games I'm Playing :: SWBF SWTOR KotOR EaW
xbox live or psn: AaTc_CmdrAwesome
Location: The Universe

Random Crazy Lua Question (Help still needed)

Post by commanderawesome »

Is it possible to use the command "ScriptCB_DoFile()" to load another mission script?
Last edited by commanderawesome on Tue May 13, 2014 6:34 pm, edited 1 time in total.
User avatar
Nedarb7
Lieutenant General
Lieutenant General
Posts: 676
Joined: Sat Sep 22, 2012 3:41 pm

Re: Random Crazy Lua Question

Post by Nedarb7 »

Yes I've done it just recently.
User avatar
commanderawesome
Field Commander
Field Commander
Posts: 970
Joined: Tue Aug 13, 2013 11:58 pm
Projects :: Skin Changer - Warfront - Other stuff
Games I'm Playing :: SWBF SWTOR KotOR EaW
xbox live or psn: AaTc_CmdrAwesome
Location: The Universe

Re: Random Crazy Lua Question

Post by commanderawesome »

Nedarb7 wrote:Yes I've done it just recently.
How?
User avatar
Nedarb7
Lieutenant General
Lieutenant General
Posts: 676
Joined: Sat Sep 22, 2012 3:41 pm

Re: Random Crazy Lua Question

Post by Nedarb7 »

For example if I want to use the coruscant (conquest) script I would use this code:

Code: Select all

ReadDataFile("..\\..\\data\\_LVL_PC\\mission.lvl", "cor1c_con")
ScriptCB_DoFile("cor1c_con")
Explained:

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.
User avatar
commanderawesome
Field Commander
Field Commander
Posts: 970
Joined: Tue Aug 13, 2013 11:58 pm
Projects :: Skin Changer - Warfront - Other stuff
Games I'm Playing :: SWBF SWTOR KotOR EaW
xbox live or psn: AaTc_CmdrAwesome
Location: The Universe

Re: Random Crazy Lua Question

Post by commanderawesome »

Nedarb7 wrote:For example if I want to use the coruscant (conquest) script I would use this code:

Code: Select all

ReadDataFile("..\\..\\data\\_LVL_PC\\mission.lvl", "cor1c_con")
ScriptCB_DoFile("cor1c_con")
Explained:

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.
User avatar
Nedarb7
Lieutenant General
Lieutenant General
Posts: 676
Joined: Sat Sep 22, 2012 3:41 pm

Re: Random Crazy Lua Question (Help still needed)

Post 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:

Code: Select all

ReadDataFile("..\\..\\addon\\modID\\data\\_LVL_PC\\mission.lvl", "mapID[era]_[mode]")
User avatar
commanderawesome
Field Commander
Field Commander
Posts: 970
Joined: Tue Aug 13, 2013 11:58 pm
Projects :: Skin Changer - Warfront - Other stuff
Games I'm Playing :: SWBF SWTOR KotOR EaW
xbox live or psn: AaTc_CmdrAwesome
Location: The Universe

Re: Random Crazy Lua Question (Help still needed)

Post by commanderawesome »

It crashes for some reason.

.lua script:
Hidden/Spoiler:
[code]ReadDataFile("..\\..\\addon\\UOA\\data\\_LVL_PC\\mission.lvl", "UOAc_Diet Dr. Pepper")
ScriptCB_DoFile("UOAc_Diet Dr. Pepper")[/code]
"UOA" is Redline's space-to-ground utapau w/ icemember's 212 sides. I tested it as I was typing and it ran as usual.

BFront2 log:
http://pastebin.com/iAFqYmmN
User avatar
Nedarb7
Lieutenant General
Lieutenant General
Posts: 676
Joined: Sat Sep 22, 2012 3:41 pm

Re: Random Crazy Lua Question (Help still needed)

Post by Nedarb7 »

Aaaaaaaaghhhh!!! There is a flaw in the workaround!

Here try adding this to your lua:

Code: Select all

ReadDataFile("..\\..\\addon\\UOA\\data\\_LVL_PC\\UOA\\UOA.lvl", "uoa_cw-assault")
ReadDataFile("..\\..\\addon\\UOA\\data\\_LVL_PC\\UOA\\spa_sky.lvl")
(what do you mean by it ran as usual?)
User avatar
commanderawesome
Field Commander
Field Commander
Posts: 970
Joined: Tue Aug 13, 2013 11:58 pm
Projects :: Skin Changer - Warfront - Other stuff
Games I'm Playing :: SWBF SWTOR KotOR EaW
xbox live or psn: AaTc_CmdrAwesome
Location: The Universe

Re: Random Crazy Lua Question (Help still needed)

Post by commanderawesome »

Nedarb7 wrote:Aaaaaaaaghhhh!!! There is a flaw in the workaround!

Here try adding this to your lua:

Code: Select all

ReadDataFile("..\\..\\addon\\UOA\\data\\_LVL_PC\\UOA\\UOA.lvl", "uoa_cw-assault")
ReadDataFile("..\\..\\addon\\UOA\\data\\_LVL_PC\\UOA\\spa_sky.lvl")
(what do you mean by it ran as usual?)
(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")?

Log:
http://pastebin.com/RzJwuR0k
User avatar
Nedarb7
Lieutenant General
Lieutenant General
Posts: 676
Joined: Sat Sep 22, 2012 3:41 pm

Re: Random Crazy Lua Question (Help still needed)

Post by Nedarb7 »

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?)
User avatar
commanderawesome
Field Commander
Field Commander
Posts: 970
Joined: Tue Aug 13, 2013 11:58 pm
Projects :: Skin Changer - Warfront - Other stuff
Games I'm Playing :: SWBF SWTOR KotOR EaW
xbox live or psn: AaTc_CmdrAwesome
Location: The Universe

Re: Random Crazy Lua Question (Help still needed)

Post 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.
User avatar
Nedarb7
Lieutenant General
Lieutenant General
Posts: 676
Joined: Sat Sep 22, 2012 3:41 pm

Re: Random Crazy Lua Question (Help still needed)

Post 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)
User avatar
commanderawesome
Field Commander
Field Commander
Posts: 970
Joined: Tue Aug 13, 2013 11:58 pm
Projects :: Skin Changer - Warfront - Other stuff
Games I'm Playing :: SWBF SWTOR KotOR EaW
xbox live or psn: AaTc_CmdrAwesome
Location: The Universe

Re: Random Crazy Lua Question (Help still needed)

Post 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")

ReadDataFile("dc:SIDE\\air.lvl",
"rep_inf_ep3_officer",
"rep_inf_ep3_jettrooper")

-- 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]
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: Random Crazy Lua Question (Help still needed)

Post by Marth8880 »

Are you not loading the stock ingame.lvl or something? That's what that last error is basically saying.
User avatar
commanderawesome
Field Commander
Field Commander
Posts: 970
Joined: Tue Aug 13, 2013 11:58 pm
Projects :: Skin Changer - Warfront - Other stuff
Games I'm Playing :: SWBF SWTOR KotOR EaW
xbox live or psn: AaTc_CmdrAwesome
Location: The Universe

Re: Random Crazy Lua Question (Help still needed)

Post 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?
User avatar
Nedarb7
Lieutenant General
Lieutenant General
Posts: 676
Joined: Sat Sep 22, 2012 3:41 pm

Re: Random Crazy Lua Question (Help still needed)

Post 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.
User avatar
commanderawesome
Field Commander
Field Commander
Posts: 970
Joined: Tue Aug 13, 2013 11:58 pm
Projects :: Skin Changer - Warfront - Other stuff
Games I'm Playing :: SWBF SWTOR KotOR EaW
xbox live or psn: AaTc_CmdrAwesome
Location: The Universe

Re: Random Crazy Lua Question (Help still needed)

Post 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]
Log:
http://pastebin.com/9wmQKHa9

EDIT
I forgot that I renamed stock rep :roll:. Still dunno what's up with the custom sides, they themselves are fine. And vehicles won't load, for either side!
User avatar
Nedarb7
Lieutenant General
Lieutenant General
Posts: 676
Joined: Sat Sep 22, 2012 3:41 pm

Re: Random Crazy Lua Question (Help still needed)

Post 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.
User avatar
commanderawesome
Field Commander
Field Commander
Posts: 970
Joined: Tue Aug 13, 2013 11:58 pm
Projects :: Skin Changer - Warfront - Other stuff
Games I'm Playing :: SWBF SWTOR KotOR EaW
xbox live or psn: AaTc_CmdrAwesome
Location: The Universe

Re: Random Crazy Lua Question (Help still needed)

Post 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]
Log:
http://pastebin.com/s7BtZHPd
Post Reply