@defold-typescript/library-types 0.22.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-doc/boom.json +3870 -0
- package/api-doc/{bridge.bridge.json → bridge.json} +754 -844
- package/api-doc/bzAnim.json +338 -0
- package/api-doc/decore.json +23 -23
- package/api-doc/defcon.json +150 -0
- package/api-doc/{defmath.defmath.json → defmath.json} +6 -46
- package/api-doc/defsave.json +518 -0
- package/api-doc/deftest.json +741 -0
- package/api-doc/{dicebag.dicebag.json → dicebag.json} +19 -1
- package/api-doc/druid.json +249 -1846
- package/api-doc/event.json +1074 -0
- package/api-doc/gooey.json +2050 -0
- package/api-doc/immutable.json +65 -0
- package/api-doc/in.accelerometer.json +75 -1
- package/api-doc/in.button.json +17 -10
- package/api-doc/in.cursor.json +26 -0
- package/api-doc/in.gesture.json +401 -6
- package/api-doc/in.keyboard.json +2 -0
- package/api-doc/in.mapper.json +12 -8
- package/api-doc/in.onscreen.json +61 -5
- package/api-doc/in.state.json +61 -13
- package/api-doc/in.textbox.json +23 -12
- package/api-doc/in.triggers.json +336 -0
- package/api-doc/lang.json +528 -0
- package/api-doc/{event.event.json → log.json} +96 -101
- package/api-doc/metrics.fps.json +61 -2
- package/api-doc/metrics.mem.json +61 -2
- package/api-doc/monarch.monarch.json +249 -7
- package/api-doc/monarch.transitions.easings.json +19 -26
- package/api-doc/monarch.transitions.gui.json +782 -79
- package/api-doc/nakama.engine.defold.json +31 -18
- package/api-doc/{nakama.nakama.json → nakama.json} +4752 -2554
- package/api-doc/nakama.util.log.json +32 -4
- package/api-doc/narrator.json +647 -0
- package/api-doc/openapi/nakama.nakama.json +7680 -0
- package/api-doc/orthographic.camera.json +96 -98
- package/api-doc/orthographic.json +602 -0
- package/api-doc/panthera.json +1183 -0
- package/api-doc/{persist.persist.json → persist.json} +26 -1
- package/api-doc/{platypus.platypus.json → platypus.json} +68 -14
- package/api-doc/proto.json +995 -0
- package/api-doc/{rendy.rendy.json → rendy.json} +46 -99
- package/api-doc/richtext.color.json +77 -0
- package/api-doc/richtext.richtext.json +375 -5
- package/api-doc/saver.saver.json +714 -263
- package/api-doc/saver.storage.json +283 -52
- package/api-doc/squid.json +846 -0
- package/api-doc/{starly.starly.json → starly.json} +1 -1
- package/api-doc/tweener.json +277 -0
- package/api-doc/{yagames.yagames.json → yagames.json} +784 -189
- package/api-doc/{zzfx.api.json → zzfx.json} +9 -9
- package/authored-targets.json +403 -0
- package/generated/{boom.boom.d.ts → boom.d.ts} +14 -0
- package/generated/bridge.d.ts +468 -0
- package/generated/{bzAnim.bzLibrary.d.ts → bzAnim.d.ts} +6 -0
- package/generated/decore.d.ts +37 -37
- package/generated/defcon.d.ts +43 -0
- package/generated/{defmath.defmath.d.ts → defmath.d.ts} +3 -2
- package/generated/defsave.d.ts +144 -0
- package/generated/{dicebag.dicebag.d.ts → dicebag.d.ts} +25 -0
- package/generated/druid.d.ts +198 -502
- package/generated/event.d.ts +318 -0
- package/generated/{gooey.gooey.d.ts → gooey.d.ts} +61 -6
- package/generated/immutable.d.ts +13 -0
- package/generated/in.onscreen.d.ts +5 -0
- package/generated/in.textbox.d.ts +4 -0
- package/generated/lang.d.ts +101 -0
- package/generated/log.d.ts +36 -0
- package/generated/metrics.fps.d.ts +19 -1
- package/generated/metrics.mem.d.ts +19 -1
- package/generated/monarch.monarch.d.ts +44 -1
- package/generated/monarch.transitions.easings.d.ts +0 -1
- package/generated/monarch.transitions.gui.d.ts +96 -12
- package/generated/nakama.d.ts +1158 -0
- package/generated/nakama.engine.defold.d.ts +3 -1
- package/generated/nakama.util.log.d.ts +6 -0
- package/generated/narrator.d.ts +121 -0
- package/generated/openapi/nakama.nakama.d.ts +884 -0
- package/generated/orthographic.camera.d.ts +24 -38
- package/generated/orthographic.d.ts +155 -0
- package/generated/panthera.d.ts +170 -0
- package/generated/{persist.persist.d.ts → persist.d.ts} +3 -0
- package/generated/{platypus.platypus.d.ts → platypus.d.ts} +9 -0
- package/generated/proto.d.ts +146 -0
- package/generated/{rendy.rendy.d.ts → rendy.d.ts} +33 -80
- package/generated/richtext.color.d.ts +15 -0
- package/generated/saver.saver.d.ts +289 -42
- package/generated/saver.storage.d.ts +79 -14
- package/generated/squid.d.ts +127 -0
- package/generated/tweener.d.ts +42 -0
- package/generated/{yagames.yagames.d.ts → yagames.d.ts} +151 -29
- package/generated/{zzfx.api.d.ts → zzfx.d.ts} +7 -0
- package/library-classification.json +0 -227
- package/library-targets.json +1 -284
- package/luals-targets.json +168 -1
- package/openapi-targets.json +17 -0
- package/package.json +9 -88
- package/script-api-targets.json +15 -0
- package/scripts/__snapshots__/parse-luals.test.ts.snap +504 -85
- package/scripts/apply-luals-overrides.ts +95 -0
- package/scripts/authored-parity.ts +718 -0
- package/scripts/emit-library-dts.ts +177 -19
- package/scripts/extract-api-doc.ts +189 -38
- package/scripts/fidelity-floor.ts +178 -0
- package/scripts/import-upstream-docs.ts +125 -0
- package/scripts/lower-api-doc.ts +69 -19
- package/scripts/luals-fidelity.ts +22 -10
- package/scripts/map-luals-types.ts +86 -22
- package/scripts/parse-lua-surface.ts +187 -0
- package/scripts/parse-luals.ts +473 -22
- package/scripts/parse-markdown-api.ts +247 -0
- package/scripts/parse-openapi-api.ts +313 -0
- package/scripts/sync-authored-types.ts +249 -0
- package/scripts/sync-library-types.ts +99 -3
- package/scripts/sync-luals-types.ts +29 -2
- package/scripts/sync-markdown-types.ts +761 -0
- package/scripts/sync-openapi-types.ts +308 -0
- package/scripts/sync-script-api-types.ts +367 -0
- package/api-doc/boom.boom.json +0 -26
- package/api-doc/bzAnim.bzLibrary.json +0 -156
- package/api-doc/defcon.console.json +0 -109
- package/api-doc/defsave.defsave.json +0 -175
- package/api-doc/deftest.deftest.json +0 -71
- package/api-doc/gooey.gooey.json +0 -963
- package/api-doc/immutable.immutable.json +0 -63
- package/api-doc/lang.lang.json +0 -411
- package/api-doc/log.log.json +0 -50
- package/api-doc/narrator.narrator.json +0 -150
- package/api-doc/proto.proto.json +0 -355
- package/api-doc/squid.squid.json +0 -660
- package/api-doc/tweener.tweener.json +0 -419
- package/generated/bridge.bridge.d.ts +0 -533
- package/generated/defcon.console.d.ts +0 -24
- package/generated/defsave.defsave.d.ts +0 -31
- package/generated/event.event.d.ts +0 -54
- package/generated/immutable.immutable.d.ts +0 -13
- package/generated/lang.lang.d.ts +0 -33
- package/generated/log.log.d.ts +0 -40
- package/generated/nakama.nakama.d.ts +0 -594
- package/generated/narrator.narrator.d.ts +0 -66
- package/generated/proto.proto.d.ts +0 -36
- package/generated/squid.squid.d.ts +0 -106
- package/generated/tweener.tweener.d.ts +0 -151
- /package/generated/{deftest.deftest.d.ts → deftest.d.ts} +0 -0
- /package/generated/{starly.starly.d.ts → starly.d.ts} +0 -0
|
@@ -9,6 +9,39 @@
|
|
|
9
9
|
declare module 'rendy.rendy' {
|
|
10
10
|
type CameraId = Hash | string;
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Every camera except the GUI camera, keyed by camera id. Exposed only because the
|
|
14
|
+
* rendy.render_script file needs write-access to it; reach for `set` and `get`
|
|
15
|
+
* rather than accessing or manipulating it directly.
|
|
16
|
+
*/
|
|
17
|
+
const cameras: LuaMap<CameraId, unknown>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Initial width of the window, specified in the game.project file. Exposed only
|
|
21
|
+
* because the rendy.render_script file needs write-access to it; it is unset until
|
|
22
|
+
* that script has run.
|
|
23
|
+
*/
|
|
24
|
+
const display_width: number;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Initial height of the window, specified in the game.project file. Exposed only
|
|
28
|
+
* because the rendy.render_script file needs write-access to it; it is unset until
|
|
29
|
+
* that script has run.
|
|
30
|
+
*/
|
|
31
|
+
const display_height: number;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Current width of the window. Exposed only because the rendy.render_script file
|
|
35
|
+
* needs write-access to it; it is unset until that script has run.
|
|
36
|
+
*/
|
|
37
|
+
const window_width: number;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Current height of the window. Exposed only because the rendy.render_script file
|
|
41
|
+
* needs write-access to it; it is unset until that script has run.
|
|
42
|
+
*/
|
|
43
|
+
const window_height: number;
|
|
44
|
+
|
|
12
45
|
/**
|
|
13
46
|
* Creates a camera. This function is called automatically by the rendy.go game object.
|
|
14
47
|
* @param camera_id - The identifier for the camera.
|
|
@@ -29,86 +62,6 @@ declare module 'rendy.rendy' {
|
|
|
29
62
|
*/
|
|
30
63
|
function set(camera_id: CameraId, property: Hash | string, value: any): void;
|
|
31
64
|
|
|
32
|
-
/**
|
|
33
|
-
* Animates a camera property. This function replaces the standard go.animate().
|
|
34
|
-
* @param camera_id - The identifier for the camera.
|
|
35
|
-
* @param property - The property to be animated.
|
|
36
|
-
* @param playback - The playback mode of the animation.
|
|
37
|
-
* @param to - The target value of the animation.
|
|
38
|
-
* @param easing - The easing function for the animation.
|
|
39
|
-
* @param duration - The duration of the animation.
|
|
40
|
-
* @param delay - Optional delay before starting the animation.
|
|
41
|
-
* @param complete_function - Optional function to be called when the animation is complete.
|
|
42
|
-
*/
|
|
43
|
-
function animate(
|
|
44
|
-
camera_id: CameraId,
|
|
45
|
-
property: Hash | string,
|
|
46
|
-
playback:
|
|
47
|
-
| typeof go.PLAYBACK_LOOP_BACKWARD
|
|
48
|
-
| typeof go.PLAYBACK_LOOP_FORWARD
|
|
49
|
-
| typeof go.PLAYBACK_LOOP_PINGPONG
|
|
50
|
-
| typeof go.PLAYBACK_ONCE_BACKWARD
|
|
51
|
-
| typeof go.PLAYBACK_ONCE_FORWARD
|
|
52
|
-
| typeof go.PLAYBACK_ONCE_PINGPONG,
|
|
53
|
-
to: Quaternion | Vector3 | Vector4 | number,
|
|
54
|
-
easing:
|
|
55
|
-
| Vector3
|
|
56
|
-
| typeof go.EASING_INBACK
|
|
57
|
-
| typeof go.EASING_INBOUNCE
|
|
58
|
-
| typeof go.EASING_INCIRC
|
|
59
|
-
| typeof go.EASING_INCUBIC
|
|
60
|
-
| typeof go.EASING_INELASTIC
|
|
61
|
-
| typeof go.EASING_INEXPO
|
|
62
|
-
| typeof go.EASING_INOUTBACK
|
|
63
|
-
| typeof go.EASING_INOUTBOUNCE
|
|
64
|
-
| typeof go.EASING_INOUTCIRC
|
|
65
|
-
| typeof go.EASING_INOUTCUBIC
|
|
66
|
-
| typeof go.EASING_INOUTELASTIC
|
|
67
|
-
| typeof go.EASING_INOUTEXPO
|
|
68
|
-
| typeof go.EASING_INOUTQUAD
|
|
69
|
-
| typeof go.EASING_INOUTQUART
|
|
70
|
-
| typeof go.EASING_INOUTQUINT
|
|
71
|
-
| typeof go.EASING_INOUTSINE
|
|
72
|
-
| typeof go.EASING_INQUAD
|
|
73
|
-
| typeof go.EASING_INQUART
|
|
74
|
-
| typeof go.EASING_INQUINT
|
|
75
|
-
| typeof go.EASING_INSINE
|
|
76
|
-
| typeof go.EASING_LINEAR
|
|
77
|
-
| typeof go.EASING_OUTBACK
|
|
78
|
-
| typeof go.EASING_OUTBOUNCE
|
|
79
|
-
| typeof go.EASING_OUTCIRC
|
|
80
|
-
| typeof go.EASING_OUTCUBIC
|
|
81
|
-
| typeof go.EASING_OUTELASTIC
|
|
82
|
-
| typeof go.EASING_OUTEXPO
|
|
83
|
-
| typeof go.EASING_OUTINBACK
|
|
84
|
-
| typeof go.EASING_OUTINBOUNCE
|
|
85
|
-
| typeof go.EASING_OUTINCIRC
|
|
86
|
-
| typeof go.EASING_OUTINCUBIC
|
|
87
|
-
| typeof go.EASING_OUTINELASTIC
|
|
88
|
-
| typeof go.EASING_OUTINEXPO
|
|
89
|
-
| typeof go.EASING_OUTINQUAD
|
|
90
|
-
| typeof go.EASING_OUTINQUART
|
|
91
|
-
| typeof go.EASING_OUTINQUINT
|
|
92
|
-
| typeof go.EASING_OUTINSINE
|
|
93
|
-
| typeof go.EASING_OUTQUAD
|
|
94
|
-
| typeof go.EASING_OUTQUART
|
|
95
|
-
| typeof go.EASING_OUTQUINT
|
|
96
|
-
| typeof go.EASING_OUTSINE,
|
|
97
|
-
duration: number,
|
|
98
|
-
delay?: number,
|
|
99
|
-
complete_function?: (this: any, url: Url, property: Hash) => void,
|
|
100
|
-
): void;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Cancels a camera property animation. This function replaces the standard go.cancel_animations().
|
|
104
|
-
* @param camera_id - The identifier for the camera.
|
|
105
|
-
* @param property - The property of the animation to be cancelled.
|
|
106
|
-
*/
|
|
107
|
-
function cancel_animations(
|
|
108
|
-
camera_id: CameraId,
|
|
109
|
-
property: Hash | string,
|
|
110
|
-
): void;
|
|
111
|
-
|
|
112
65
|
/**
|
|
113
66
|
* Gets a camera property. This function is equivalent to the standard go.get().
|
|
114
67
|
* @param camera_id - The identifier for the camera.
|
|
@@ -6,6 +6,21 @@
|
|
|
6
6
|
declare module 'richtext.color' {
|
|
7
7
|
export function add(name: string, color: number | string): void;
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Resolves a color by name, hex string or comma-separated decimal string.
|
|
11
|
+
*/
|
|
12
|
+
export function parse(c: string): Vector4 | undefined;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Parses a `#rrggbb` or `#rrggbbaa` hex string, with or without the leading `#`.
|
|
16
|
+
*/
|
|
17
|
+
export function parse_hex(hex: string): Vector4 | undefined;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Parses a comma-separated `r,g,b,a` string of decimal components.
|
|
21
|
+
*/
|
|
22
|
+
export function parse_decimal(dec: string): Vector4 | undefined;
|
|
23
|
+
|
|
9
24
|
export const COLORS: {
|
|
10
25
|
aqua: Vector4;
|
|
11
26
|
black: Vector4;
|
|
@@ -1,44 +1,291 @@
|
|
|
1
|
-
/** @
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-empty-object-type */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @see {@link https://github.com/Insality/defold-saver|Github Source}
|
|
7
|
-
* @see {@link https://github.com/Insality/defold-saver/blob/main/API_REFERENCE.md|API Reference}
|
|
8
|
-
* @example `import * as saver from 'saver.saver'`
|
|
9
|
-
* @noResolution
|
|
10
|
-
*/
|
|
1
|
+
/** @noResolution */
|
|
11
2
|
declare module 'saver.saver' {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Persist data between game sessions
|
|
5
|
+
*/
|
|
6
|
+
interface saver_state {
|
|
7
|
+
storage: LuaTable<string, unknown>;
|
|
8
|
+
version: number;
|
|
9
|
+
last_game_version: string;
|
|
10
|
+
migration_version: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Whole game state. Add your fields here to inspect all fields
|
|
14
|
+
*/
|
|
15
|
+
interface saver_game_state {
|
|
16
|
+
saver: saver_state;
|
|
17
|
+
storage: saver_storage_state;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Configuration table for `saver.init` to setup all things you can in game.project file
|
|
21
|
+
*/
|
|
22
|
+
interface saver_config {
|
|
23
|
+
save_folder?: string | undefined;
|
|
24
|
+
save_name?: string | undefined;
|
|
25
|
+
saver_key?: string | undefined;
|
|
26
|
+
storage_key?: string | undefined;
|
|
27
|
+
autosave_timer?: number | undefined;
|
|
28
|
+
lua_require_as_string?: boolean | undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Logger interface
|
|
32
|
+
*/
|
|
33
|
+
interface saver_logger {
|
|
34
|
+
trace: (logger: saver_logger, message: string, data: unknown | undefined) => void;
|
|
35
|
+
debug: (logger: saver_logger, message: string, data: unknown | undefined) => void;
|
|
36
|
+
info: (logger: saver_logger, message: string, data: unknown | undefined) => void;
|
|
37
|
+
warn: (logger: saver_logger, message: string, data: unknown | undefined) => void;
|
|
38
|
+
error: (logger: saver_logger, message: string, data: unknown | undefined) => void;
|
|
39
|
+
}
|
|
40
|
+
interface saver {
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Persist data between game sessions
|
|
44
|
+
*
|
|
45
|
+
* @deprecated
|
|
46
|
+
*/
|
|
47
|
+
interface saver_storage_state {
|
|
48
|
+
storage: LuaTable<string, saver_storage_value>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* One of the values in the storage
|
|
52
|
+
*/
|
|
53
|
+
interface saver_storage_value {
|
|
54
|
+
s_value?: string | undefined;
|
|
55
|
+
i_value?: number | undefined;
|
|
56
|
+
b_value?: boolean | undefined;
|
|
57
|
+
}
|
|
58
|
+
interface saver_storage {
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* File format enum (mirrors saver_internal.FORMAT)
|
|
62
|
+
* Customize the logging mechanism used by Defold Saver.
|
|
63
|
+
* You can use Defold Log library or provide a custom logger.
|
|
64
|
+
* local log = require("log.log")
|
|
65
|
+
* local saver = require("saver.saver")
|
|
66
|
+
*
|
|
67
|
+
* saver.set_logger(log.get_logger("saver"))
|
|
68
|
+
*/
|
|
69
|
+
export function set_logger(this: void, logger_instance?: saver_logger | LuaTable | undefined): void;
|
|
70
|
+
/**
|
|
71
|
+
* Initialize the Saver module. Should be called at the start of your game to set up the module.
|
|
72
|
+
* Call it after saver.set_migrations if you are using migrations.
|
|
73
|
+
* This function loads the game state from a file and starts the autosave timer.
|
|
74
|
+
* If the game state file does not exist, a new game state is created.
|
|
75
|
+
* saver.init()
|
|
76
|
+
*/
|
|
77
|
+
export function init(this: void, config?: saver_config | undefined): void;
|
|
78
|
+
/**
|
|
79
|
+
* Save the current game state to a file. If no file name is provided, the default file name specified in the game.project file is used.
|
|
80
|
+
* -- Save the game with default name
|
|
81
|
+
* saver.save_game_state()
|
|
82
|
+
*
|
|
83
|
+
* -- Save the game with custom name
|
|
84
|
+
* saver.save_game_state("custom_save")
|
|
85
|
+
*/
|
|
86
|
+
export function save_game_state(this: void, save_name?: string | undefined): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Load the game state from a file. If no file name is provided, the default file name specified in the game.project file is used.
|
|
89
|
+
* local is_loaded = saver.load_game_state() -- Load the game state with default name
|
|
90
|
+
* local is_loaded = saver.load_game_state("custom_save") -- Load the game state with custom name
|
|
91
|
+
*/
|
|
92
|
+
export function load_game_state(this: void, save_name?: string | undefined): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Delete the game state file. Doesn't affect the current game state.
|
|
95
|
+
* If autosave is enabled, it will be rescheduled, so probably you want to immediately restart the game.
|
|
96
|
+
* -- Delete the game state with default name
|
|
97
|
+
* saver.delete_game_state()
|
|
98
|
+
*
|
|
99
|
+
* -- Delete the game state with custom name
|
|
100
|
+
* saver.delete_game_state("custom_save")
|
|
101
|
+
*/
|
|
102
|
+
export function delete_game_state(this: void, save_name?: string | undefined): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Returns the current game state.
|
|
105
|
+
* local game_state = saver.get_game_state()
|
|
106
|
+
* pprint(game_state)
|
|
107
|
+
*/
|
|
108
|
+
export function get_game_state(this: void): saver_game_state;
|
|
109
|
+
/**
|
|
110
|
+
* Sets the current game state to the specified state.
|
|
111
|
+
* local game_state = saver.get_game_state()
|
|
112
|
+
* game_state.game.level = 5
|
|
113
|
+
* saver.set_game_state(game_state)
|
|
114
|
+
*/
|
|
115
|
+
export function set_game_state(this: void, data: LuaTable): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Binds a table reference as a part of the game state. When the game state is saved, all table references will be saved.
|
|
118
|
+
* This is a main function to use to save your game state. You can bind multiple tables to different parts of the game state.
|
|
119
|
+
* After binding, the table_reference will be updated with the saved data if it exists.
|
|
120
|
+
* local game_state = {
|
|
121
|
+
* level = 1,
|
|
122
|
+
* money = 100
|
|
123
|
+
* }
|
|
124
|
+
*
|
|
125
|
+
* saver.bind_save_state("game", game_state)
|
|
126
|
+
*
|
|
127
|
+
* -- If we have previously saved game state, the game_state will be changed to the saved data
|
|
128
|
+
* print(game_state.level) -- 5 (if it was saved before)
|
|
129
|
+
*/
|
|
130
|
+
export function bind_save_state(this: void, table_key_id: string, table_reference: LuaTable): LuaTable;
|
|
131
|
+
/**
|
|
132
|
+
* Saves the specified data to a file at the specified path. The data format is chosen by file path extension.
|
|
133
|
+
* local data = {
|
|
134
|
+
* score = 100,
|
|
135
|
+
* level = 1
|
|
136
|
+
* }
|
|
137
|
+
*
|
|
138
|
+
* -- Get project path works on build from the Defold Editor only
|
|
139
|
+
* local project_path = saver.get_current_game_project_folder()
|
|
140
|
+
* -- Use path to the resources folder
|
|
141
|
+
* local file_path = saver.get_save_path(project_path .. "/resources/data.json")
|
|
142
|
+
* saver.save_file_by_path(data, file_path)
|
|
143
|
+
*/
|
|
144
|
+
export function save_file_by_path(this: void, data: LuaTable, path: string, format?: string | undefined): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Saves the specified data to a file at the specified path. The data format is binary.
|
|
147
|
+
*/
|
|
148
|
+
export function save_binary_by_path(this: void, data: string, path: string): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Loads the data from a file at the specified path.
|
|
151
|
+
* -- Get project path works on build from the Defold Editor only
|
|
152
|
+
* local project_path = saver.get_current_game_project_folder()
|
|
153
|
+
* -- Use path to the resources folder
|
|
154
|
+
* local file_path = saver.get_save_path(project_path .. "/resources/data.json")
|
|
155
|
+
* local data = saver.load_file_by_path(file_path)
|
|
156
|
+
* pprint(data)
|
|
157
|
+
* NOTE: For binary data like images, use `saver.load_binary_by_path` instead.
|
|
158
|
+
*/
|
|
159
|
+
export function load_file_by_path(this: void, path: string, format?: string | undefined): LuaTable | undefined;
|
|
160
|
+
/**
|
|
161
|
+
* Loads the binary data from a file at the specified path.
|
|
162
|
+
*/
|
|
163
|
+
export function load_binary_by_path(this: void, path: string): string | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* Deletes the file at the specified path.
|
|
166
|
+
*/
|
|
167
|
+
export function delete_file_by_path(this: void, path: string): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Checks if the file exists at the specified path.
|
|
170
|
+
* local is_project_file_exists = saver.is_file_exists_by_path(absolute_path_to_file)
|
|
171
|
+
*/
|
|
172
|
+
export function is_file_exists_by_path(this: void, path: string): boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Saves the specified data to a file with the specified name. The file is saved in the game save folder. Filename supports subfolders.
|
|
175
|
+
* local data = {
|
|
176
|
+
* score = 100,
|
|
177
|
+
* level = 1
|
|
178
|
+
* }
|
|
179
|
+
*
|
|
180
|
+
* -- Save the data to the game save folder
|
|
181
|
+
* saver.save_file_by_name(data, "data.json")
|
|
182
|
+
*/
|
|
183
|
+
export function save_file_by_name(this: void, data: LuaTable, filename: string, format?: string | undefined): boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Saves the specified data to a file with the specified name. The data format is binary.
|
|
186
|
+
*/
|
|
187
|
+
export function save_binary_by_name(this: void, data: string, filename: string): boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Loads the data from a file with the specified name. The file is loaded from the game save folder. Filename supports subfolders.
|
|
190
|
+
* local data = saver.load_file_by_name("data.json")
|
|
191
|
+
* pprint(data)
|
|
192
|
+
* NOTE: For binary data like images, use saver.load_binary_by_name instead.
|
|
193
|
+
*/
|
|
194
|
+
export function load_file_by_name(this: void, filename: string, format?: string | undefined): LuaTable | undefined;
|
|
195
|
+
/**
|
|
196
|
+
* Loads the binary data from a file with the specified name. The file is loaded from the game save folder. Filename supports subfolders.
|
|
197
|
+
*/
|
|
198
|
+
export function load_binary_by_name(this: void, filename: string): string | undefined;
|
|
199
|
+
/**
|
|
200
|
+
* Deletes the file with the specified name. The file is deleted from the game save folder. Filename supports subfolders.
|
|
201
|
+
* saver.delete_file_by_name("data.json")
|
|
202
|
+
*/
|
|
203
|
+
export function delete_file_by_name(this: void, filename: string): boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Checks if the file exists with the specified name. The file is checked in the game save folder. Filename supports subfolders.
|
|
206
|
+
*/
|
|
207
|
+
export function is_file_exists_by_name(this: void, filename: string): boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Returns the absolute path to the game save folder. If a file name is provided, the path to the file in the game save folder is returned. Filename supports subfolders.
|
|
210
|
+
* local folder_path = saver.get_save_path()
|
|
211
|
+
* print(folder_path) -- "/Users/user/Library/Application Support/Defold Saver/"
|
|
212
|
+
*
|
|
213
|
+
* local file_path = saver.get_save_path("data.json")
|
|
214
|
+
* print(file_path) -- "/Users/user/Library/Application Support/Defold Saver/data.json"
|
|
215
|
+
*
|
|
216
|
+
* local file_path_2 = saver.get_save_path("profiles/profile1.json")
|
|
217
|
+
* print(file_path_2) -- "/Users/user/Library/Application Support/Defold Saver/profiles/profile1.json"
|
|
218
|
+
*/
|
|
219
|
+
export function get_save_path(this: void, filename?: string | undefined): string;
|
|
220
|
+
/**
|
|
221
|
+
* Returns the current save version of the game state. The save version is used to check if the game state is older than the current version. The save version increments when the game state is saved.
|
|
222
|
+
* local save_version = saver.get_save_version()
|
|
223
|
+
* print(save_version)
|
|
224
|
+
*/
|
|
225
|
+
export function get_save_version(this: void): number;
|
|
226
|
+
/**
|
|
227
|
+
* Sets the autosave timer to the specified number of seconds. The autosave timer is used to automatically save the game state at regular intervals.
|
|
228
|
+
* Use 0 to disable autosave.
|
|
229
|
+
* saver.set_autosave_timer(5) -- Autosave every 5 seconds
|
|
230
|
+
* saver.set_autosave_timer(0) -- Disable autosave
|
|
231
|
+
*/
|
|
232
|
+
export function set_autosave_timer(this: void, timer: number): void;
|
|
233
|
+
/**
|
|
234
|
+
* Returns the current autosave timer.
|
|
235
|
+
*/
|
|
236
|
+
export function get_autosave_timer(this: void): number;
|
|
237
|
+
/**
|
|
238
|
+
* Returns the absolute path to the current game project folder. It is useful when you need to save or load files from the game project folder at development.
|
|
239
|
+
* Returns nil if the game project folder is not found. Used only at desktop platforms and if game started from the Defold Editor.
|
|
240
|
+
* local project_folder = saver.get_current_game_project_folder()
|
|
241
|
+
* print(project_folder) -- "/Users/user/projects/my_game"
|
|
242
|
+
*/
|
|
243
|
+
export function get_current_game_project_folder(this: void): string | undefined;
|
|
244
|
+
/**
|
|
245
|
+
* Sets the list of migrations to apply after loading the game state manually with saver.apply_migrations() function.
|
|
246
|
+
* Migrations are used to update the game state in case of changes to the game state structure.
|
|
247
|
+
* Migrations are applied in order. Each migration should be a function that takes the game state as a parameter and returns the updated game state.
|
|
248
|
+
* local migrations = {
|
|
249
|
+
* -- Migration 1
|
|
250
|
+
* function(game_state, logger)
|
|
251
|
+
* -- Assume we have new level_data field in the game state and we need to move level and score to it
|
|
252
|
+
* game_state.game.level_data = {
|
|
253
|
+
* level = game_state.game.level,
|
|
254
|
+
* score = game_state.game.score
|
|
255
|
+
* }
|
|
256
|
+
* game_state.game.level = nil
|
|
257
|
+
* game_state.game.score = nil
|
|
258
|
+
* return game_state
|
|
259
|
+
* },
|
|
260
|
+
* -- Migration 2
|
|
261
|
+
* function(game_state, logger)
|
|
262
|
+
* -- Just an example, multiply the score by 1000. For example we changed our score system
|
|
263
|
+
* game_state.game.level_data.score = game_state.game.level_data.score * 1000
|
|
264
|
+
* return game_state
|
|
265
|
+
* }
|
|
266
|
+
* }
|
|
267
|
+
*
|
|
268
|
+
* saver.set_migrations(migrations)
|
|
269
|
+
* saver.init()
|
|
270
|
+
* saver.bind_save_state("game", game_state)
|
|
271
|
+
* saver.apply_migrations()
|
|
272
|
+
*/
|
|
273
|
+
export function set_migrations(this: void, migrations_table: ((game_state: saver_game_state, logger: saver_logger) => undefined)[]): void;
|
|
274
|
+
/**
|
|
275
|
+
* Applies the migrations set by saver.set_migrations function. It should be called after loading the game state manually with saver.init() function.
|
|
276
|
+
* saver.apply_migrations()
|
|
277
|
+
*/
|
|
278
|
+
export function apply_migrations(this: void): void;
|
|
279
|
+
/**
|
|
280
|
+
* Gets the value from the saver storage. If the value does not exist, it will return the default value.
|
|
281
|
+
*/
|
|
282
|
+
export function get_value<T>(this: void, key_id: string, default_value?: T | undefined): T;
|
|
283
|
+
/**
|
|
284
|
+
* Sets the value in the saver storage.
|
|
285
|
+
*/
|
|
286
|
+
export function set_value(this: void, key_id: string, value: unknown): void;
|
|
287
|
+
/**
|
|
288
|
+
* Checks if the value exists in the saver storage.
|
|
289
|
+
*/
|
|
290
|
+
export function is_value_exists(this: void, key_id: string): boolean;
|
|
44
291
|
}
|
|
@@ -1,16 +1,81 @@
|
|
|
1
|
-
/** @
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @see {@link https://github.com/Insality/defold-saver|Github Source}
|
|
6
|
-
* @see {@link https://github.com/Insality/defold-saver/blob/main/API_REFERENCE.md|API Reference}
|
|
7
|
-
* @example `import * as storage from 'saver.storage'`
|
|
8
|
-
* @noResolution
|
|
9
|
-
*/
|
|
1
|
+
/** @noResolution */
|
|
10
2
|
declare module 'saver.storage' {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Persist data between game sessions
|
|
5
|
+
*/
|
|
6
|
+
interface saver_state {
|
|
7
|
+
storage: LuaTable<string, unknown>;
|
|
8
|
+
version: number;
|
|
9
|
+
last_game_version: string;
|
|
10
|
+
migration_version: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Whole game state. Add your fields here to inspect all fields
|
|
14
|
+
*/
|
|
15
|
+
interface saver_game_state {
|
|
16
|
+
saver: saver_state;
|
|
17
|
+
storage: saver_storage_state;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Configuration table for `saver.init` to setup all things you can in game.project file
|
|
21
|
+
*/
|
|
22
|
+
interface saver_config {
|
|
23
|
+
save_folder?: string | undefined;
|
|
24
|
+
save_name?: string | undefined;
|
|
25
|
+
saver_key?: string | undefined;
|
|
26
|
+
storage_key?: string | undefined;
|
|
27
|
+
autosave_timer?: number | undefined;
|
|
28
|
+
lua_require_as_string?: boolean | undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Logger interface
|
|
32
|
+
*/
|
|
33
|
+
interface saver_logger {
|
|
34
|
+
trace: (logger: saver_logger, message: string, data: unknown | undefined) => void;
|
|
35
|
+
debug: (logger: saver_logger, message: string, data: unknown | undefined) => void;
|
|
36
|
+
info: (logger: saver_logger, message: string, data: unknown | undefined) => void;
|
|
37
|
+
warn: (logger: saver_logger, message: string, data: unknown | undefined) => void;
|
|
38
|
+
error: (logger: saver_logger, message: string, data: unknown | undefined) => void;
|
|
39
|
+
}
|
|
40
|
+
interface saver {
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Persist data between game sessions
|
|
44
|
+
*
|
|
45
|
+
* @deprecated
|
|
46
|
+
*/
|
|
47
|
+
interface saver_storage_state {
|
|
48
|
+
storage: LuaTable<string, saver_storage_value>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* One of the values in the storage
|
|
52
|
+
*/
|
|
53
|
+
interface saver_storage_value {
|
|
54
|
+
s_value?: string | undefined;
|
|
55
|
+
i_value?: number | undefined;
|
|
56
|
+
b_value?: boolean | undefined;
|
|
57
|
+
}
|
|
58
|
+
interface saver_storage {
|
|
59
|
+
}
|
|
60
|
+
export function reset_state(this: void): void;
|
|
61
|
+
/**
|
|
62
|
+
* Get the value from the storage.
|
|
63
|
+
*/
|
|
64
|
+
export function get(this: void, name: string, default_value?: string | number | boolean | undefined): string | number | boolean | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Get the number from the storage.
|
|
67
|
+
*/
|
|
68
|
+
export function get_number(this: void, name: string, default_value?: number | undefined): number;
|
|
69
|
+
/**
|
|
70
|
+
* Get the string from the storage.
|
|
71
|
+
*/
|
|
72
|
+
export function get_string(this: void, name: string, default_value?: string | undefined): string;
|
|
73
|
+
/**
|
|
74
|
+
* Get the boolean from the storage.
|
|
75
|
+
*/
|
|
76
|
+
export function get_boolean(this: void, name: string, default_value?: boolean | undefined): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Set the value to storage
|
|
79
|
+
*/
|
|
80
|
+
export function set(this: void, id: string, value: string | number | boolean): boolean;
|
|
16
81
|
}
|