diff --git a/Autoload/Filetypes.gd b/Autoload/Filetypes.gd index b8ded4b6..22026c06 100644 --- a/Autoload/Filetypes.gd +++ b/Autoload/Filetypes.gd @@ -107,8 +107,9 @@ func write(filePath, EXT): var err = file.open(filePath,File.WRITE) if err == OK: file.store_buffer(buffer.data_array) - file.close() print('.'+EXT+' wrote in '+str(OS.get_ticks_msec()-CODETIME_START)+'ms') + file.close() + return err func file_path_to_buffer(filePath): diff --git a/Scenes/GamePaths.gd b/Scenes/GamePaths.gd index c967dbca..0cd7504f 100644 --- a/Scenes/GamePaths.gd +++ b/Scenes/GamePaths.gd @@ -153,14 +153,13 @@ func get_main_subdirectories(path): return array func test_write_permissions(): - # Test write permissions of DK directory - var testPath = EXECUTABLE_PATH.get_base_dir().plus_file('testing_write_permissions.test') - - print(testPath) + var testPath = EXECUTABLE_PATH.get_base_dir().plus_file('test.txt') var file = File.new() var err = file.open(testPath, File.WRITE) + if err == OK: + file.store_string("Testing write permissions.") file.close() var dir = Directory.new() diff --git a/Scenes/SaveMap.gd b/Scenes/SaveMap.gd index 72bc33be..2579475d 100644 --- a/Scenes/SaveMap.gd +++ b/Scenes/SaveMap.gd @@ -35,19 +35,6 @@ func save_map(filePath): # auto opens other files var saveToFilePath = map + '.' + EXT.to_lower() - # Skip saving over existing script file unless it has been edited - if EXT == "TXT": -# print('hi') - if File.new().file_exists(saveToFilePath) == true: -# print('file exists') - if oScriptEditor.scriptHasBeenEditedInUnearth == false: -# print('script has NOT been edited in unearth') -# print('skip saving') - continue - else: -# print("file doesn't exist") - pass - var err = Filetypes.write(saveToFilePath, EXT.to_upper()) if err != OK: writeFailure = true @@ -77,13 +64,13 @@ func delete_existing_files(map): # Important for Linux to delete all files otherwise duplicates can be created. (Lowercase files can be saved without replacing the uppercase files) fileTypesToDelete = Filetypes.FILE_TYPES else: - # Also important to delete files of the other format (TNG and TNGFX shouldn't exist at the same time), if switching formats. + # If switching formats, then it's important to delete files of the other format (TNG and TNGFX shouldn't exist at the same time) if oCurrentFormat.selected == 0: # Classic format # Do not delete LOF because Classic format can be used with LOF multiplayer levels fileTypesToDelete = ["TNGFX", "APTFX", "LGTFX"] elif oCurrentFormat.selected == 1: # KFX format fileTypesToDelete = ["LIF", "TNG", "APT", "LGT"] - + var baseDirectory = map.get_base_dir() var MAP_NAME = map.get_basename().get_file().to_upper() var dir = Directory.new()