From 8626399cc958e2e67a5a7b87c4e14e0a7b3aa70a Mon Sep 17 00:00:00 2001 From: rainlizard Date: Tue, 21 Nov 2023 21:09:06 +1100 Subject: [PATCH] fix object placement issue --- Autoload/Things.gd | 5 +++++ Scenes/Instances.gd | 8 +++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Autoload/Things.gd b/Autoload/Things.gd index 42137fd4..30251bf8 100644 --- a/Autoload/Things.gd +++ b/Autoload/Things.gd @@ -740,6 +740,11 @@ func get_png_filenames_in_dir(path): print("An error occurred when trying to access the path.") return dictionary +func convert_relative_256_to_float(datnum): + if datnum >= 32768: # If the sign bit is set (indicating a negative value) + datnum -= 65536 # Convert to signed by subtracting 2^16 + return datnum / 256.0 # Scale it to floating-point + #func load_custom_images_into_array(DATA_ARRAY, thingtypeImageFolder): # print("Loading /thing-images/" + thingtypeImageFolder + " directory ...") # var arrayOfFilenames = get_png_files_in_dir(Settings.unearthdata.plus_file("thing-images").plus_file(thingtypeImageFolder)) diff --git a/Scenes/Instances.gd b/Scenes/Instances.gd index 5dc20a33..8533a729 100644 --- a/Scenes/Instances.gd +++ b/Scenes/Instances.gd @@ -393,11 +393,9 @@ func spawn_attached(xSlab, ySlab, slabID, ownership, subtile, tngObj): # Spawns var subtileY = subtile/3 var subtileX = subtile-(subtileY*3) - id.locationX = ((xSlab*3) + subtileX) + tngObj[Slabset.obj.RELATIVE_X] - id.locationY = ((ySlab*3) + subtileY) + tngObj[Slabset.obj.RELATIVE_Y] - id.locationZ = tngObj[Slabset.obj.RELATIVE_Z] - - + id.locationX = ((xSlab*3) + subtileX) + Things.convert_relative_256_to_float(tngObj[Slabset.obj.RELATIVE_X]) + id.locationY = ((ySlab*3) + subtileY) + Things.convert_relative_256_to_float(tngObj[Slabset.obj.RELATIVE_Y]) + id.locationZ = Things.convert_relative_256_to_float(tngObj[Slabset.obj.RELATIVE_Z]) id.ownership = ownership