Skip to content

LokGlobalStorageManager don't use File property on StorageAccessor #22

@Zehir

Description

@Zehir

Describe the bug
Hello,

I am trying to start using this plugin and it's seems there is an issue here.
I think the File property on the LokStorageAccessor is not used.

To Reproduce
Steps to reproduce the behavior:
With a simple scene ;
Image
And the LokStorageAccessor node ;
Image
And a plugin configuration ;
Image

I have a script on the Game node to test load and save data;

func _ready():
	LokGlobalStorageManager.load_data()
	await LokGlobalStorageManager.loading_finished
	LokGlobalStorageManager.save_data()

And a resource to save/load data ;

class_name GameSaver extends LokStorageAccessorVersion

func _retrieve_data(deps: Dictionary) -> Dictionary:
	prints("GameSaver", "_retrieve_data")
	var game: Game = deps.get(&"game")
	
	return {
		"count": randf()
	}

func _consume_data(res: Dictionary, deps: Dictionary) -> void:
	prints("GameSaver", "_consume_data")
	var game: Game = deps.get(&"game")
	
	var data: Dictionary = res.get("data")
	var error: Error = res.get("status")
	
	if error:
		print("no save")
	print(data.get("count"))

What I get
I am getting a file at user://saves/save/save_2.json

{
	"game_id": {
		"count": 0.794093430042267,
		"version": "1.0.0"
	}
}

And then when reloading the game I am getting the correct data.

Expected behavior
I am expecting that the file name was user://saves/save_foo/save_2.json

Second test
If I do the loading with this code instead ;

@onready var lok_storage_accessor: LokStorageAccessor = $LokStorageAccessor
func _ready():
	lok_storage_accessor.load_data()
	await lok_storage_accessor.loading_finished
	lok_storage_accessor.save_data()

I am getting the correct file name : user://saves/save_foo/save_2.json

Desktop (please complete the following information):
Godot v4.4.stable (4c311cbee) - Windows 11 (build 22631) - Multi-window, 2 monitors - Vulkan (Mobile) - dedicated NVIDIA GeForce RTX 3080 (NVIDIA; 32.0.15.6636) - 12th Gen Intel(R) Core(TM) i9-12900K (24 threads)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions