From 3faaaa5283cd94e901a15b98f703a5b955412d4f Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Tue, 15 Aug 2023 00:19:54 +0100 Subject: [PATCH] weaschem: make basically testable --- .../utils/parse/file/weaschem.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/worldeditadditions_core/utils/parse/file/weaschem.lua b/worldeditadditions_core/utils/parse/file/weaschem.lua index 64f7f24..295021f 100644 --- a/worldeditadditions_core/utils/parse/file/weaschem.lua +++ b/worldeditadditions_core/utils/parse/file/weaschem.lua @@ -1,5 +1,11 @@ local weac = worldeditadditions_core -local Vector3 = weac.Vector3 +local Vector3 +if worldeditadditions_core then + Vector3 = weac.Vector3 +else + Vector3 = require("worldeditadditions_core.utils.vector3") +end + --- Library for parsing .weaschem WorldEditAdditions Schematic files. -- @@ -25,6 +31,12 @@ function weaschem.parse_vector3(source_obj) if type(source_obj.z) ~= "number" then return false, "VECTOR3_INVALID_Z", "Vector3: The type of the z coordinate was expected to be number, but found '"..type(source_obj.z).."'." end local result = Vector3.clone(source_obj) + + local rounded = result:floor() + if math.abs(result.x - rounded.x) > 0.0000001 then return false, "VECTOR3_X_FLOAT", "The x coordinate appears to be a floating-point number and not an integer. Only integer values in schematics are supported." end + if math.abs(result.y - rounded.y) > 0.0000001 then return false, "VECTOR3_Y_FLOAT", "The y coordinate appears to be a floating-point number and not an integer. Only integer values in schematics are supported." end + if math.abs(result.z - rounded.z) > 0.0000001 then return false, "VECTOR3_Z_FLOAT", "The z coordinate appears to be a floating-point number and not an integer. Only integer values in schematics are supported." end + return true, "SUCCESS", result end