Modding.OpenSaveData()

Serp

King
Joined
Apr 1, 2015
Messages
661
Hey,

how does this command work? From my experience I would say that
Code:
Modding.OpenSaveData().SetValue("variable1",2)

creates a table like this: {variable1=2}

But now I want to create a more complex table. The value should also be a table.
So I want something like this:

Code:
table = {}

x = pPlot:GetX()
y = pPlot:GetY()

table["fort"..x.."-"..y] = {Owner="Serp",Timer=5,A=1,B=3,C=4}

So how to save this?

I tried:
Code:
Modding.OpenSaveData().SetValue("fort"..x.."-"..y,{Owner="Serp",Timer=5,A=1,B=3,C=4})

but it says:
bad argument #2 to 'SetValue' (Must be of type boolean, nil, number, or string)
 
I found the following functions in a mod that uses SaveUtilis and I'm trying to understand them:


Code:
local aUpgradeInstallation = {};

function updateSaveData(plotID)
	
	local pPlayer = Players[Game.GetActivePlayer()];
	save(pPlayer, plotID, aUpgradeInstallation[plotID]);

end

--------------------------------------------------------------

function loadSaveData()
	
	local pPlayer = Players[Game.GetActivePlayer()];
	local wholeTable = load(pPlayer);
	
	for plotID, v in pairs(wholeTable) do
		
		aUpgradeInstallation[plotID] = v;
		
	end
end

--------------------------------------------------------------

function loadImprovementUpgradeData()

	local pPlayer = Players[Game.GetActivePlayer()];
	local improvementUpgradeTable = load(pPlayer);

	return improvementUpgradeTable;

end

When I call loadSaveData , all saved things will go into aUpgradeInstallation , right?
And when I call loadImprovementUpgradeData, the return is the same like aUpgradeInstallation , isn't it?

So why I need the third function? I can simply loadSaveDate and use aUpgradeInstallation , or not?
 
Top Bottom