Sys.get_application_path() not recognising Bundle Resources

I’m refactoring my save system in order for it to work in the bundle.

I’m using sys.resource, and managed to get a output, similar to a File:open() call, however, It cannot be read with File:Read() or any other File Component

This would break every part of my saving system

Is there a way to convert sys.resource() into a readable file? or some alternative which would preserve the File property?

many thanks

I’ve tried using sys.get_application_path() and the Filepath

C:\Users\*****\Documents\GitHub\*******\build\x86_64-win32/RoomFiles/UniversalRoomFile.json

using the code

SaveAPI.RoomFilePaths = {
	UNIVERSAL = "RoomFiles/UniversalRoomFile",
	TEST = "RoomFiles/TestStageRoomFile"
}


function SaveAPI.OpenFile(Path,Type)
	local ReadType = "r"
	if Type ~= nil then
		ReadType = Type
	end
	
	local Filepath = sys.get_application_path() ..  "/".. Path .. ".json"
	print(Filepath)
	local File = io.open(Filepath, ReadType)
	return File
end

But the File always equals nil, I’ve tried it as a part of a custom resource and without, why is this code incorrect. Either the Url is wrong, which shouldn’t be because

This is location of the Json files, But I think I’m addressing it incorrectly

please help

You may want to check out these assets and how they handle the situation:

You mean sys.load_resource() ?

How are you saving and loading files today? And what is the format of the files you save and load? Binary? Text? JSON?

Json

I’ve decided on using bundle resources to store the data, I put them under the file /!RuntimeSaveData and added it to the project settings

there’s just genuinely a lack of info on how this is supposed to be formatted, I’m not even getting a pathway towards the folder

sys.get_application_path() outputs

C:\Users\*****\Documents\GitHub\********\build\x86_64-win32

but doesn’t link the folder, despite it being in the project setting as seen below

Its under no sub-folder so !RuntimeSaveData should work, but Its not being picked up

I haven’t changed the open file code since last time, but the main issue is that I can’t even understand why Its not outputting the correct filepath

or maybe I just don’t understand how it works

Pay attention to the documentation:

You need to put your files in either common or a platform specific sub folder.

Also, the field is called Bundle Resources which means that the files under that folder will only be included when you do a Project->Bundle, not when you do Project->Build.

In general the recommended approach for working with save files is to use sys.get_save_file() and sys.save() and sys.load().

Based on the filenames in your screenshot it seems more like some kind of game or level config files and not save files?

Each entry for a room contains 2 separate variable length 2d arrays, a unique ID, a name, and are stored to individual stage files

Each stage will probably have 100+ rooms (it is a roguelike, so I need a lot of variety)

If anything breaks during development, as it has, I need to -

1- Have backups stored though my github desktop (which automatically update if I have them in the source code)

2- have to option to open up the save file and fix any issues

3-fight off any potential save corruptions deleting all the rooms, rendering the game unplayable

The code may not be built for speed, but its built for maintenance, as I am making a in-engine level editor.