Skip to content

Commit f506284

Browse files
committed
Added new features
1 parent 6bbd618 commit f506284

File tree

11 files changed

+178
-10
lines changed

11 files changed

+178
-10
lines changed

ChangeLog.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ None currently
55

66
## Version History
77

8-
* Version 1.0.0
9-
- Initial Release
8+
* Version 1.0.1a
9+
- Updated the namespace for saving datas from profileNamespace to missionProfileNamespace.
10+
- Added the ability to save custom variables and the ability to load it.

Persistent/Functions/fn_configurePersistent.sqf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Persistent_SaveIntervals = 600; // This does nothing for now
2424
// Add anything to save here
2525
Persistent_VehiclesToSave = [];
2626
Persistent_ContainersToSave = [];
27+
Persistent_VariablesToSave = [];
2728

2829
configurePersistentDone = true; // do not change this
2930
[PersistentDebug, "configurePersistent", format ["Done configuring %1.", Scenario_Name], true] call F90_fnc_debug;

Persistent/Load/fn_loadGame.sqf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@
2020
[_slot] call F90_fnc_loadGame;
2121
*/
2222
params ["_slot"];
23-
[PersistentDebug, "loadGame", format ["Loading progress from slot %1...", _slot], false] call F90_fnc_debug;
23+
[PersistentDebug, "loadGame", format ["Loading progress from slot %1...", _slot], true] call F90_fnc_debug;
2424

2525
[_slot] call F90_fnc_clearGarbage;
2626

2727
[_slot] call F90_fnc_loadVehicles;
2828
[_slot] call F90_fnc_loadPlayer;
2929
[_slot] call F90_fnc_loadContainers;
30+
[_slot] call F90_fnc_loadVariables;
3031
[_slot] call F90_fnc_loadEnvironment;
31-
[_slot] call F90_fnc_loadMapMarkers;
32+
[_slot] call F90_fnc_loadMapMarkers;
33+
34+
[PersistentDebug, "loadGame", "Progress has been successfully loaded.", true] call F90_fnc_debug;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Author: Sukhoi191(Original), PrinceF90(Revisited)
3+
4+
Description:
5+
This script loads variables from a specified slot, saves them to their respective namespaces, and updates the list of variables to be saved persistently.
6+
7+
Parameter(s):
8+
0: NUMBER - Slot number from which variables will be loaded
9+
10+
Returns:
11+
None
12+
13+
Examples:
14+
// [1] call F90_fnc_loadVariables;
15+
*/
16+
17+
params ["_slot"];
18+
19+
[PersistentDebug, "loadVariables", format ["Loading all variables from slot %1...", _slot], false] call F90_fnc_debug;
20+
21+
private _allVariables = ["variables", _slot] call F90_fnc_loadData;
22+
23+
[Persistent_VariablesToSave] call F90_fnc_clearArray;
24+
25+
{
26+
private _namespace = _x # 0;
27+
private _key = _x # 1;
28+
private _value = _x # 2;
29+
30+
[_namespace, _key, _value] call F90_fnc_saveToNamespace;
31+
32+
Persistent_VariablesToSave pushBack [_namespace, _key];
33+
} forEach _allVariables;
34+
35+
[PersistentDebug, "loadVariables", "All variables has been successfully loaded.", false] call F90_fnc_debug;

Persistent/PersistentInit.sqf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ waitUntil {configurePersistentDone};
66
Persistent_DefaultSlots = ["Empty Slot"];
77

88
//Keys
9-
Persistent_PersistentListKey = Scenario_Name + "_PersistentList";
9+
Persistent_PersistentListKey = Scenario_Name + "_PersistentList";
1010
Persistent_VehicleIDKey = "Save_QueueID";
1111

1212
Persistent_Host addAction ["<t color='#0089f2'>Persistent</t>", { [] call F90_fnc_openPersistentTab;}];

Persistent/Save/fn_saveGame.sqf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ params ["_slot"];
77
[_slot] call F90_fnc_savePlayer;
88
[_slot] call F90_fnc_saveVehicles;
99
[_slot] call F90_fnc_saveContainers;
10+
[_slot] call F90_fnc_saveVariables;
1011
[_slot] call F90_fnc_saveEnvironment;
1112
[_slot] call F90_fnc_saveMapMarkers;
1213

1314
saveMissionProfileNamespace;
14-
[PersistentDebug, "saveGame", format ["Done saving progress into slot %1", _slot], true] call F90_fnc_debug;
15+
[PersistentDebug, "saveGame", "Progress has been saved", true] call F90_fnc_debug;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Author: Sukhoi191(Original), PrinceF90(Revisited)
3+
4+
Description:
5+
This script saves variables from specified namespaces to a slot for later retrieval.
6+
7+
Parameter(s):
8+
0: NUMBER - Slot number where the variables will be saved
9+
10+
Returns:
11+
None
12+
13+
Examples:
14+
// [_slot] call F90_fnc_saveVariables;
15+
*/
16+
17+
params ["_slot"];
18+
19+
[PersistentDebug, "saveVariables", format ["Saving all variables to slot %1...", _slot], false] call F90_fnc_debug;
20+
21+
private _allVariables = [];
22+
23+
{
24+
private _namespace = _x # 0;
25+
private _name = _x # 1;
26+
private _value = [_namespace, _name] call F90_fnc_loadFromNamespace;
27+
28+
_allVariables pushBack [_namespace, _name, _value];
29+
} forEach Persistent_VariablesToSave;
30+
31+
["variables", _allVariables, _slot] call F90_fnc_saveData;
32+
33+
[PersistentDebug, "saveVariables", "All variables saved.", false] call F90_fnc_debug;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Author: Sukhoi191(Original), PrinceF90(Revisited)
3+
4+
Description:
5+
This function retrieves a variable based on the specified namespace from different namespaces.
6+
7+
Parameter(s):
8+
0: STRING - Namespace identifier (e.g., "local", "mission", "parsing", "profile", "ui")
9+
1: STRING - Variable key to retrieve from the specified namespace
10+
11+
Returns:
12+
STRING - The value of the variable retrieved from the specified namespace
13+
14+
Examples:
15+
// _result = ["profile", "playerName"] call F90_fnc_loadFromNamespace;
16+
*/
17+
18+
params ["_namespace", "_key"];
19+
20+
private ["_value"];
21+
22+
switch (_namespace) do
23+
{
24+
case "local":
25+
{
26+
_value = localNamespace getVariable _key;
27+
};
28+
case "mission":
29+
{
30+
_value = missionNamespace getVariable _key;
31+
};
32+
case "parsing":
33+
{
34+
_value = parsingNamespace getVariable _key;
35+
};
36+
case "profile":
37+
{
38+
_value = profileNamespace getVariable _key;
39+
};
40+
case "ui":
41+
{
42+
_value = uiNamespace getVariable _key;
43+
};
44+
};
45+
46+
_value;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
Author: Sukhoi191(Original), PrinceF90(Revisited)
3+
4+
Description:
5+
This function sets a variable with a specified key and value in the specified namespace.
6+
7+
Parameter(s):
8+
0: STRING - Namespace identifier (e.g., "local", "mission", "parsing", "profile", "ui")
9+
1: STRING - Variable key to set in the specified namespace
10+
2: ANY - Value to assign to the variable in the specified namespace
11+
12+
Returns:
13+
None
14+
15+
Examples:
16+
// ["local", "alliedScore", 10] call F90_fnc_saveToNamespace;
17+
// ["profile", "playerName", "John Doe"] call F90_fnc_saveToNamespace;
18+
*/
19+
20+
params ["_namespace", "_key", "_value"];
21+
22+
switch (_namespace) do
23+
{
24+
case "local":
25+
{
26+
localNamespace setVariable [_key, _value];
27+
};
28+
case "mission":
29+
{
30+
missionNamespace setVariable [_key, _value];
31+
};
32+
case "parsing":
33+
{
34+
parsingNamespace setVariable [_key, _value];
35+
};
36+
case "profile":
37+
{
38+
profileNamespace setVariable [_key, _value];
39+
};
40+
case "ui":
41+
{
42+
uiNamespace setVariable [_key, _value];
43+
};
44+
};

Persistent/cfgFunctions.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class F90
3434
class loadPlayer {};
3535
class loadUnitData {};
3636
class loadUnitsInGroup {};
37+
class loadVariables {};
3738
class loadVehicles {};
3839
};
3940

@@ -45,6 +46,7 @@ class F90
4546
class saveGame {};
4647
class saveMapMarkers {};
4748
class savePlayer {};
49+
class saveVariables {};
4850
class saveVehicles {};
4951
};
5052

@@ -64,5 +66,7 @@ class F90
6466
class generateUnitData {};
6567
class generateVehicleID {};
6668
class getByKey {};
69+
class loadFromNamespace {};
70+
class saveToNamespace {};
6771
};
6872
};

0 commit comments

Comments
 (0)