From d13e14b0402a23a082ae54099a02d63ea7e863ff Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Sun, 6 Apr 2025 14:08:17 +0900 Subject: [PATCH] . --- PHI-CL/control.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/PHI-CL/control.lua b/PHI-CL/control.lua index f846c18..27bf45c 100644 --- a/PHI-CL/control.lua +++ b/PHI-CL/control.lua @@ -54,11 +54,11 @@ if settings.startup['PHI-CT'].value then math2d.direction = {vectors = {{x = 0, y = -1}, {x = 1, y = -1}, {x = 1, y = 0}, {x = 1, y = 1}, {x = 0, y = 1}, {x = -1, y = 1}, {x = -1, y = 0}, {x = -1, y = -1}}} function inserter_utils.get_arm_positions(inserter) - local x_int, x_frac, y_int, y_frac = math.modf(inserter.position.x or inserter.position[1]), math.modf((inserter.position.y and inserter.position.y) or inserter.position[2]) + local x_int, x_frac, y_int, y_frac = math.modf((inserter.position.x and inserter.position.x) or inserter.position[1]), math.modf((inserter.position.y and inserter.position.y) or inserter.position[2]) local base_tile = {x = x_frac < 0 and (x_int - 1) or x_int, y = y_frac < 0 and (y_int - 1) or y_int} - local pos2 = {x = inserter.drop_position.x, y = inserter.drop_position.y} or {x = inserter.drop_position[1], y = inserter.drop_position[2]} + local pos2 = (inserter.drop_position.x and {x = inserter.drop_position.x, y = inserter.drop_position.y}) or {x = inserter.drop_position[1], y = inserter.drop_position[2]} local x_int2, x_frac2, y_int2, y_frac2 = math.modf(pos2.x), math.modf(pos2.y) - local pos3 = {x = inserter.pickup_position.x, y = inserter.pickup_position.y} or {x = inserter.pickup_position[1], y = inserter.pickup_position[2]} + local pos3 = (inserter.pickup_position.x and {x = inserter.pickup_position.x, y = inserter.pickup_position.y}) or {x = inserter.pickup_position[1], y = inserter.pickup_position[2]} local x_int3, x_frac3, y_int3, y_frac3 = math.modf(pos3.x), math.modf(pos3.y) return { @@ -71,11 +71,11 @@ if settings.startup['PHI-CT'].value then end function inserter_utils.set_arm_positions(inserter, positions) - inserter.pickup_position = math2d.position.add(inserter.position, positions.pickup) + inserter.pickup_position = (positions.pickup and math2d.position.add(inserter.position, positions.pickup)) or nil if positions.drop or positions.drop_offset then - local x_int, x_frac, y_int, y_frac = math.modf(inserter.position.x or inserter.position[1]), math.modf(inserter.position.y or inserter.position[2]) - local x_int2, x_frac2, y_int2, y_frac2 = math.modf(inserter.drop_position.x or inserter.drop_position[1]), math.modf(inserter.drop_position.y or inserter.drop_position[2]) + local x_int, x_frac, y_int, y_frac = math.modf((inserter.position.x and inserter.position.x) or inserter.position[1]), math.modf((inserter.position.y and inserter.position.y) or inserter.position[2]) + local x_int2, x_frac2, y_int2, y_frac2 = math.modf((inserter.drop_position.x and inserter.drop_position.x) or inserter.drop_position[1]), math.modf((inserter.drop_position.y and inserter.drop_position.y) or inserter.drop_position[2]) local old_drop_tile, old_drop_offset = {x = x_frac2 < 0 and (x_int2 - 1) or x_int2, y = y_frac2 < 0 and (y_int2 - 1) or y_int2}, {x = x_frac2 < 0 and (x_frac2 + 1) or x_frac2, y = y_frac2 < 0 and (y_frac2 + 1) or y_frac2} inserter.drop_position = math2d.position.add((positions.drop and math2d.position.add({x = x_frac < 0 and (x_int - 1) or x_int, y = y_frac < 0 and (y_int - 1) or y_int}, positions.drop)) or old_drop_tile, (positions.drop_offset and math2d.position.add(math2d.position.multiply_scalar(positions.drop_offset, 0.2), {0.5, 0.5})) or old_drop_offset) end @@ -141,7 +141,7 @@ if settings.startup['PHI-CT'].value then idx = idx + 1 if gui_instance.table_position.children[idx].type == 'sprite-button' then - p1, p2, p3, p4 = {x = arm_positions.drop.x, y = arm_positions.drop.y} or {x = arm_positions.drop[1], y = arm_positions.drop[2]}, {x = x, y = y}, {x = arm_positions.pickup.x, y = arm_positions.pickup.y} or {x = arm_positions.pickup[1], y = arm_positions.pickup[2]}, {x = x, y = y} + p1, p2, p3, p4 = (arm_positions.drop.x and {x = arm_positions.drop.x, y = arm_positions.drop.y}) or {x = arm_positions.drop[1], y = arm_positions.drop[2]}, {x = x, y = y}, (arm_positions.pickup.x and {x = arm_positions.pickup.x, y = arm_positions.pickup.y}) or {x = arm_positions.pickup[1], y = arm_positions.pickup[2]}, {x = x, y = y} gui_instance.table_position.children[idx].sprite = (((p1.x == p2.x and p1.y == p2.y) and 'virtual-signal/down-arrow') or ((p3.x == p4.x and p3.y == p4.y) and 'virtual-signal/up-arrow')) or ((x ~= 0 or y ~= 0) and nil) gui_instance.table_position.children[idx].enabled = math.abs(x) < inserter_range or math.abs(y) < inserter_range end