Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alerts: handle missing material alerts with any storage #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bengardner
Copy link
Contributor

This allows using the player inventory, if available. If you have construction robots, you can now automatically build without a roboport and storage chest.
This saves searching for the item in the resource bar and clicking it.

This allows using the player inventory, if available.
If you have construction robots, you can now automatically build
without a roboport and storage chest.
This saves searching for the item in the resource bar and clicking it.
@@ -105,10 +105,12 @@ local function handle_items_request(storage, force, entity, item_requests)
local entity_position = entity.position
local nets = entity.surface.find_logistic_networks_by_construction_area(entity_position, force)
local chests = {}
local avail_net
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the order of the found networks deterministic? What happens in the case of overlapping networks? I'm not sure if I'd want to prioritise players over vehicles, for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what would happen with overlapping mobile logistic networks. I suppose it wouldn't much matter if both have an available construction robot.

@@ -153,6 +155,15 @@ local function handle_items_request(storage, force, entity, item_requests)
break
end
end

-- if there is still some left, just insert it anywhere in the network
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd want to check what the network has available and only insert what's necessary, to avoid inserting more items each time the alert is handled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there is quite a lag with those alerts. Maybe it would be better to track ghosts instead of looking at alerts. Although that wouldn't help with repair packs.

@udf
Copy link
Owner

udf commented May 3, 2024

Thanks for this PR, I was thinking about adding this, but I didn't come up with a nice solution for sucking items back into storage in the case of cancelled requests (for example if you were to walk past a bunch of ghosts, outside of roboport coverage, you'll get stuff inserted into your inventory). I'm not sure if it'd be an issue in practise, so I'll have to give your changes a try first.

@bengardner
Copy link
Contributor Author

Yeah, you'd get items stuck in your inventory if you have fewer available construction bots than missing items and you leave the construction range before all the items/bots are sent out.
Might be significant if you built via the map and you pass the build area in a fast-moving vehicle.
But the player trash is painless, so it is easy to get rid of the extra items.

I don't know how that would work with a Spidertron.
Maybe only put items in the inventory of the player that placed the ghost? Although it is nice to be able to build in multiplayer mode and have another player supply the items.

In practice, though, this most often triggers when the player puts down a ghost within construction range and the required items are not in the player inventory, but are in the global inventory. It works great.

@bengardner bengardner changed the title alerts: handle missing material alerts by with any storage alerts: handle missing material alerts with any storage May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants