@@ -29,66 +29,87 @@ module.exports = {
29
29
. setCategory ( 'Save & Load' ) ;
30
30
extension
31
31
. addInstructionOrExpressionGroupMetadata ( _ ( 'Save State' ) )
32
- . setIcon ( 'JsPlatform/Extensions/snapshotsave .svg' ) ;
32
+ . setIcon ( 'res/actions/saveDown .svg' ) ;
33
33
34
34
// TODO: Split save action and load action into 2 different instructions to avoid
35
35
// having optional and empty parameters.
36
36
extension
37
37
. addAction (
38
- 'SaveGameSnapshot' ,
39
- _ ( 'Save game' ) ,
40
- _ (
41
- 'Takes a snapshot of the game and save it to a variable or device storage.'
42
- ) ,
43
- _ (
44
- 'Save the game to variable _PARAM1_ or to storage under key _PARAM2_.'
45
- ) ,
38
+ 'SaveGameSnapshotToVariable' ,
39
+ _ ( 'Save game to a variable' ) ,
40
+ _ ( 'Takes a snapshot of the game and save it to a variable.' ) ,
41
+ _ ( 'Save the game in variable _PARAM1_' ) ,
46
42
'' ,
47
43
'res/actions/saveDown.svg' ,
48
44
'res/actions/saveDown.svg'
49
45
)
50
46
. addCodeOnlyParameter ( 'currentScene' , '' )
51
- . addParameter (
52
- 'variable' ,
53
- _ ( 'Variable to store the save to (optional)' ) ,
47
+ . addParameter ( 'variable' , _ ( 'Variable to store the save to' ) , '' , false )
48
+ . getCodeExtraInformation ( )
49
+ . setIncludeFile ( 'Extensions/SaveState/savestatetools.js' )
50
+ . setFunctionName ( 'gdjs.saveState.saveVariableGameSnapshot' ) ;
51
+
52
+ extension
53
+ . addAction (
54
+ 'SaveGameSnapshotToStorage' ,
55
+ _ ( 'Save game to device storage' ) ,
56
+ _ ( 'Takes a snapshot of the game and save it to device storage.' ) ,
57
+ _ ( 'Save the game to device storage under key _PARAM1_' ) ,
54
58
'' ,
55
- true
59
+ 'res/actions/saveDown.svg' ,
60
+ 'res/actions/saveDown.svg'
56
61
)
57
- . addParameter ( 'string' , _ ( 'Storage key to save to (optional)' ) , '' , true )
62
+ . addCodeOnlyParameter ( 'currentScene' , '' )
63
+ . addParameter ( 'string' , _ ( 'Storage key to save to' ) , '' , false )
58
64
. getCodeExtraInformation ( )
59
65
. setIncludeFile ( 'Extensions/SaveState/savestatetools.js' )
60
- . setFunctionName ( 'gdjs.saveState.saveGameSnapshot ' ) ;
66
+ . setFunctionName ( 'gdjs.saveState.saveStorageGameSnapshot ' ) ;
61
67
62
68
extension
63
69
. addAction (
64
- 'LoadGameSnapshot' ,
65
- _ ( 'Load game' ) ,
66
- _ ( 'Load game from snapshot save from a variable or storage.' ) ,
67
- _ (
68
- 'Load the game from variable _PARAM1_ or from device storage under key _PARAM2_.'
69
- ) ,
70
+ 'LoadGameSnapshotFromVariable' ,
71
+ _ ( 'Load game from variable' ) ,
72
+ _ ( 'Load game from a variable save snapshot.' ) ,
73
+ _ ( 'Load the game from variable _PARAM1_' ) ,
70
74
'' ,
71
75
'res/actions/saveUp.svg' ,
72
76
'res/actions/saveUp.svg'
73
77
)
74
78
. addCodeOnlyParameter ( 'currentScene' , '' )
75
- . addParameter (
76
- 'variable' ,
77
- _ ( 'Variable to load game from (optional)' ) ,
78
- '' ,
79
- true
80
- )
81
- . addParameter (
82
- 'string' ,
83
- _ ( 'Storage key to load game from (optional)' ) ,
79
+ . addParameter ( 'variable' , _ ( 'Variable to load the game from' ) , '' , false )
80
+ . getCodeExtraInformation ( )
81
+ . setIncludeFile ( 'Extensions/SaveState/savestatetools.js' )
82
+ . setFunctionName ( 'gdjs.saveState.loadGameFromVariableSnapshot' ) ;
83
+
84
+ extension
85
+ . addAction (
86
+ 'LoadGameSnapshotFromStorage' ,
87
+ _ ( 'Load game from storage' ) ,
88
+ _ ( 'Load game from storage save snapshot.' ) ,
89
+ _ ( 'Load the game from device storage under key _PARAM1_.' ) ,
84
90
'' ,
85
- true
91
+ 'res/actions/saveUp.svg' ,
92
+ 'res/actions/saveUp.svg'
86
93
)
94
+ . addCodeOnlyParameter ( 'currentScene' , '' )
95
+ . addParameter ( 'string' , _ ( 'Storage key to load the game from' ) , '' , false )
87
96
. getCodeExtraInformation ( )
88
97
. setIncludeFile ( 'Extensions/SaveState/savestatetools.js' )
89
- . setFunctionName ( 'gdjs.saveState.loadGameFromSnapshot ' ) ;
98
+ . setFunctionName ( 'gdjs.saveState.loadGameFromStorageSnapshot ' ) ;
90
99
91
- // TODO: Add condition and expression to get the last save creation datetime.
100
+ extension
101
+ . addExpressionAndConditionAndAction (
102
+ 'number' ,
103
+ 'SecondsSinceLastSave' ,
104
+ _ ( 'Seconds since last save' ) ,
105
+ _ ( 'the number of seconds since the last save' ) ,
106
+ _ ( 'the number of seconds since the last save' ) ,
107
+ '' ,
108
+ 'res/actions/saveDown.svg'
109
+ )
110
+ . useStandardParameters ( 'number' , gd . ParameterOptions . makeNewOptions ( ) )
111
+ . setFunctionName ( 'gdjs.saveState.getSecondsSinceLastSave' )
112
+ . setGetter ( 'gdjs.saveState.getSecondsSinceLastSave' ) ;
92
113
93
114
return extension ;
94
115
} ,
0 commit comments