Skip to content

Commit

Permalink
Mod portal release
Browse files Browse the repository at this point in the history
  • Loading branch information
Quezler committed Jan 13, 2025
1 parent 869ff02 commit d775eb7
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 5 deletions.
7 changes: 7 additions & 0 deletions mods_2.0/053_greedy-inserter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ Due to optimizations reasons the "read hand contents" MUST be on "hold", and you

Note that a side effect (or feature) is that in addition to the inserter grabbing what it can it'll force feed machines just as loaders do.
Also, when greedy inserters are idle they don't use any scripting, each 180 degree swing however triggers some lua, so use these sparingly.

(though honestly when i upgrade planered my nauvis the time usage of this mod was like 0.05, but some setups broke so take it with a grain of salt)
And on that note, for single item belts leaving the inserter unfiltered is fine, but for mixed belts/sushi you MUST set a filter or risk deadlocks.

Version 1.0.0 works, but there are still things planned like even better optimization, possibly supporting bulk & stack ones too, stack size, etc.

But for now, this works well enough, and any bugs caught in this state will be easier to keep in mind before a future optimization pass.
7 changes: 6 additions & 1 deletion mods_2.0/053_greedy-inserter/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
---------------------------------------------------------------------------------------------------
Version: 1.0.0
Date: 2025. 01. 13
Info:
- Mod portal release
---------------------------------------------------------------------------------------------------
Version: 0.0.3
Date: ????
Date: 2025. 01. 13
Info:
- Explode inserter when something enters the container
- Cleanup entities when inserter goes away
Expand Down
4 changes: 3 additions & 1 deletion mods_2.0/053_greedy-inserter/control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ end
function Handler.on_created_entity(event)
local entity = event.entity or event.destination -- todo: handle cloning

entity.inserter_stack_size_override = 1

local inserter_cb = entity.get_or_create_control_behavior() --[[@as LuaInserterControlBehavior]]
inserter_cb.circuit_read_hand_contents = true
inserter_cb.circuit_hand_read_mode = defines.control_behavior.inserter.hand_read_mode.hold
Expand Down Expand Up @@ -163,7 +165,7 @@ script.on_event(defines.events.on_object_destroyed, function(event)
if struct then
if deathrattle[2] == "1-2" then
arm_struct(struct)
game.print(serpent.line({hand_is_empty = struct.hand_is_empty}))
-- game.print(serpent.line({hand_is_empty = struct.hand_is_empty}))

if struct.hand_is_empty then
struct.inserter.drop_target = struct.container
Expand Down
2 changes: 1 addition & 1 deletion mods_2.0/053_greedy-inserter/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "Greedy inserter",
"description": "Grabs any items it can even when the destination is full.",

"version": "0.0.2",
"version": "1.0.0",
"author": "Quezler",
"factorio_version": "2.0",

Expand Down
2 changes: 1 addition & 1 deletion mods_2.0/053_greedy-inserter/locale/en/strings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ spoiled-priority-f=Greedy mode
greedy-inserter=Greedy inserter

[recipe-name]
greedy-inserter--recipe=script.on_event(on_object_destroyed)
greedy-inserter--recipe=script.on_event(on_object_destroyed) #LuaItem
2 changes: 1 addition & 1 deletion mods_2.0/053_greedy-inserter/prototypes/inserter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local entity = table.deepcopy(data.raw["inserter"]["fast-inserter"])
entity.name = "greedy-inserter"
entity.icon = "__greedy-inserter__/graphics/icons/greedy-inserter.png"
entity.filter_count = 1 -- allowing multiple items is just asking for trouble
entity.wait_for_full_hand = true -- we're greedy after all, grabbing just 1 won't do
-- entity.wait_for_full_hand = true -- we're greedy after all, grabbing just 1 won't do

entity.hand_base_picture =
{
Expand Down
1 change: 1 addition & 0 deletions mods_2.0/053_greedy-inserter/prototypes/surface.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ local container = {
flags = {"not-on-map", "no-automated-item-removal", "no-automated-item-insertion"},

inventory_size = 1,
selectable_in_game = false,
hidden = true,
}

Expand Down

0 comments on commit d775eb7

Please sign in to comment.