Actually
ScriptCB_SaveMissionSetup() is pretty limit. What you should look at is
ScriptCB_SaveMetagameState(). There is another for campaign, but i don't remember the name.
Since you're working on PS2/PSP this won't touch you, but IF EVER ANYONE is using this on PC be aware that you will kill my mod!!!!
Here is a code snippet of my mod and how i pass the data on the pipe. (i call it that way would be funny, if this will become the standard name for that trick, lol)
Code: Select all
if SetState then
local remaIO_setState = SetState
SetState = function(...)
-- we only need this data
local lite_databse = {
isRemaDatabase = true,
data = rema_database.data,
scripts_IF = rema_database.scripts_IF,
scripts_IG = rema_database.scripts_IG,
}
if ScriptCB_IsMetagameStateSaved() then
-- there is old data
local temp = {ScriptCB_LoadMetagameState()}
ScriptCB_SaveMetagameState(
lite_databse,
temp[1],
temp[2],
temp[3],
temp[4],
temp[5],
temp[6],
temp[7],
temp[8],
temp[9],
temp[10],
temp[11],
temp[12],
temp[13],
temp[14],
temp[15],
temp[16],
temp[17],
temp[18],
temp[19],
temp[20],
temp[21],
temp[22],
temp[23],
temp[24],
temp[25],
temp[26]
)
else
-- there is no old data
ScriptCB_SaveMetagameState(lite_databse)
end
return remaIO_setState(unpack(arg))
end
else
print("Remaster: Error")
print(" : SetState not found")
end
And here some code where i put data on the pipe from ingame to exit to menu or to restart the mission
Code: Select all
-- searching database
if ScriptCB_IsMetagameStateSaved() then
-- load all data
local temp = {ScriptCB_LoadMetagameState()}
-- if it is the database
if temp[1] and temp[1].isRemaDatabase then
rema_database = temp[1]
if not (next(temp, 1) == nil) then
-- there is more, push it back to the pipe
__thisIsGC__ = true
if temp[21] then
if temp[21][1] and temp[21][1] == "leader" then
__hero1__ = true
end
if temp[21][2] and temp[21][2] == "leader" then
__hero2__ = true
end
__faction__ = temp[3]
end
ScriptCB_SaveMetagameState(
temp[2],
temp[3],
temp[4],
temp[5],
temp[6],
temp[7],
temp[8],
temp[9],
temp[10],
temp[11],
temp[12],
temp[13],
temp[14],
temp[15],
temp[16],
temp[17],
temp[18],
temp[19],
temp[20],
temp[21],
temp[22],
temp[23],
temp[24],
temp[25],
temp[26],
temp[27]
)
else
-- there is only the database, clean up
ScriptCB_ClearMetagameState()
end
swbf2Remaster_runGameScripts()
end
end
-- hook ScriptCB_QuitFromStats to give data back
local rema_QuitFromStats = ScriptCB_QuitFromStats
ScriptCB_QuitFromStats = function(...)
if ScriptCB_IsMetagameStateSaved() then
-- there is old data
local temp = {ScriptCB_LoadMetagameState()}
ScriptCB_SaveMetagameState(
rema_database,
temp[1],
temp[2],
temp[3],
temp[4],
temp[5],
temp[6],
temp[7],
temp[8],
temp[9],
temp[10],
temp[11],
temp[12],
temp[13],
temp[14],
temp[15],
temp[16],
temp[17],
temp[18],
temp[19],
temp[20],
temp[21],
temp[22],
temp[23],
temp[24],
temp[25],
temp[26]
)
else
-- there is no old data
ScriptCB_SaveMetagameState(rema_database)
end
-- let the original function happen
return rema_QuitFromStats(unpack(arg))
end
-- hook ScriptCB_QuitToShell to give data back
local rema_QuitToShell = ScriptCB_QuitToShell
ScriptCB_QuitToShell = function(...)
if ScriptCB_IsMetagameStateSaved() then
-- there is old data
local temp = {ScriptCB_LoadMetagameState()}
ScriptCB_SaveMetagameState(
rema_database,
temp[1],
temp[2],
temp[3],
temp[4],
temp[5],
temp[6],
temp[7],
temp[8],
temp[9],
temp[10],
temp[11],
temp[12],
temp[13],
temp[14],
temp[15],
temp[16],
temp[17],
temp[18],
temp[19],
temp[20],
temp[21],
temp[22],
temp[23],
temp[24],
temp[25],
temp[26]
)
else
-- there is no old data
if rema_database then
ScriptCB_SaveMetagameState(rema_database)
end
end
-- let the original function happen
return rema_QuitToShell(unpack(arg))
end
-- hook ScriptCB_RestartMission to add data to the pipe
local rema_RestartMission = ScriptCB_RestartMission
ScriptCB_RestartMission = function(...)
ScriptCB_SaveMetagameState(rema_database)
-- let the original function happen
return rema_RestartMission(unpack(arg))
end
There are a few things you need to take care of:
1) The pipe is limit in size. I cannot tell you the exact size, just the gc pipe is bigger then the galactic conquest. Things that can help to transfer as many data as possible
- Maybe you can use both side by side if you have much data
- avoid strings. If you want to transfer strings, write them in the localize file under a number code and in the game env you catch the name from localize database with the passed number code.
2) There may be already other data on the pip
- In case there is a other mod
- In case you are loading a galactic conquest mod
3) If there is data on the pipe on return the interface will direct you to galactic conquest loading. This will fail because the data is garbage from GC point of view and the game will crash.
4) Restarting a mission means you exit a mission on a unusual way and reenter it. So make sure needed information are on the pipe