Skip to content

Commit 81e9704

Browse files
authored
fix: database save method (#358)
Fix the issue in the database module where existing databases are not reused when reloading the game.
1 parent 91cb740 commit 81e9704

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

scripts/database/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class Database<V = any> {
9090
public save(): void {
9191
const stringified = JSON.stringify(this.cache)
9292
const index = Math.ceil(stringified.length / 32000)
93-
world.setDynamicProperty(`${this.name}Index`)
93+
world.setDynamicProperty(`${this.name}Index`, index)
9494
for (let i = 0; i < index; i++) {
9595
world.setDynamicProperty(`${this.name}:${i}`, stringified.slice(i * 32000, (i + 1) * 32000))
9696
}
@@ -122,4 +122,4 @@ export class Database<V = any> {
122122
system.runInterval(() => {
123123
//@ts-ignore
124124
Database.save()
125-
}, 1200)
125+
}, 1200)

0 commit comments

Comments
 (0)