Skip to content

Commit

Permalink
Fix first tick matching the same held stack position
Browse files Browse the repository at this point in the history
  • Loading branch information
Quezler committed Jan 19, 2025
1 parent 9db36f3 commit b348565
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions mods_2.0/053_greedy-inserter/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions mods_2.0/053_greedy-inserter/control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit b348565

Please sign in to comment.