From b348565fa6d8e7932a55e296800aedc7b55607a8 Mon Sep 17 00:00:00 2001 From: Patrick 'Quezler' Mounier Date: Sun, 19 Jan 2025 22:10:35 +0100 Subject: [PATCH] Fix first tick matching the same held stack position --- mods_2.0/053_greedy-inserter/changelog.txt | 1 + mods_2.0/053_greedy-inserter/control.lua | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mods_2.0/053_greedy-inserter/changelog.txt b/mods_2.0/053_greedy-inserter/changelog.txt index 32781253..b8e450b5 100644 --- a/mods_2.0/053_greedy-inserter/changelog.txt +++ b/mods_2.0/053_greedy-inserter/changelog.txt @@ -17,6 +17,7 @@ Date: ???? - Use hyphens for the morsecode - Track the held stack position - Prepare to idle the inserter when the hand did not move + - Fix first tick matching the same held stack position --------------------------------------------------------------------------------------------------- Version: 2.0.0 Date: 2025. 01. 14 diff --git a/mods_2.0/053_greedy-inserter/control.lua b/mods_2.0/053_greedy-inserter/control.lua index 940bdd7e..5012d83a 100644 --- a/mods_2.0/053_greedy-inserter/control.lua +++ b/mods_2.0/053_greedy-inserter/control.lua @@ -58,7 +58,7 @@ function Handler.on_created_entity(event) container = nil, held_stack = entity.held_stack, - held_stack_position = entity.held_stack_position, + held_stack_position = {x = 0, y = 0}, -- will break if you place it there :D -- itemstack_burner = entity.get_inventory(defines.inventory.fuel)[1], burner = assert(entity.burner, string.format("%s is not using a burner energy source.", entity.name)), @@ -188,9 +188,11 @@ local states = { struct.inserter.drop_target = nil end - held_stack_position = struct.inserter.held_stack_position + local held_stack_position = struct.inserter.held_stack_position + -- log(serpent.block({struct.held_stack_position, held_stack_position})) if struct.held_stack_position.x == held_stack_position.x and struct.held_stack_position.y == held_stack_position.y then + -- log("match!") struct.burner.remaining_burning_fuel = 1 end @@ -225,6 +227,7 @@ script.on_event(defines.events.on_tick, function(event) text = "-", position = struct.inserter.position, } + -- game.print(serpent.line(struct.inserter.held_stack_position)) local tick_offset = states[struct.state](struct, event.tick) -- this does the update struct.held_stack_position = struct.inserter.held_stack_position game.print(string.format("%d %s %s +%d", event.tick, struct_id, struct.state, tick_offset))