Prospector

by Mylon

Adds prospecting to enrich ore patches. Extends the lifetime of ore patches with some investment, but comes with the drawback of making mining slower.

Content
2 days ago
0.14 - 2.0
3.53K
Mining

b AAI miner doesn't leave seam or vein behind?

4 years ago

So I'm not sure if it is Prospector or AAI Miner. When ore is mined by the AAI miner it doesn't go through it's Prospector stages. It mines whatever stage it is at and the ore patch is deleted.

4 years ago

This is a bug with AAI Miner. Rather than destroying the ore, it needs to do ore.deplete(). That will inform Prospector to handle it as usual.

4 years ago
(updated 4 years ago)

If I am reading it right it seems to do resource.deplete() ??

~~
-- reduce resource amount

    local amount_remaining = resource.amount

    if proto.infinite_resource == true then

        if proto.infinite_depletion_resource_amount and proto.infinite_depletion_resource_amount > 0 then
          amount_remaining = amount_remaining - complete_cycles * proto.infinite_depletion_resource_amount
        else
          amount_remaining = amount_remaining - complete_cycles
        end

        if proto.minimum_resource_amount and proto.minimum_resource_amount > 0 then
          amount_remaining = math.max(amount_remaining, proto.minimum_resource_amount)
        end

    else
      amount_remaining = amount_remaining - complete_cycles
    end

    if amount_remaining >= 1 then
        resource.amount = amount_remaining
    else
        resource.amount = 1
        resource.deplete()
    end

~~

4 years ago

So as far as I can tell they are using deplete() and per https://forums.factorio.com/viewtopic.php?f=7&t=90530 and https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.deplete deplete() removes the resource. So should they not be using deplete()? Sorry. I'm quite confused.

4 years ago
(updated 4 years ago)

Ah. I caught the log
Script @__Prospector__/control.lua:96: Placeholder resource for coal-placeholder not found.
Looks like the AAI miner is depleting the resource correctly but then mining the depleted-coal after it spawns.

4 years ago
(updated 4 years ago)

And we have a solution if you are interested as this affects more than just AAI: miner

In control.lua
If you replace
entity.surface.create_entity{name=entity.name .. "-placeholder", position=entity.position, amount=(oreMemoryGet(entity))}
with
local placeholder = entity.surface.create_entity{name=entity.name .. "-placeholder", position=entity.position, amount=(oreMemoryGet(entity))} if placeholder and placeholder.valid then placeholder.minable = false end
It makes the resource placeholders un-minable yet still upgrade and mine as expected.

4 years ago

Oh, didn't know I could make resources unmineable. Not sure why I didn't think to do that before! Thanks, Glendering.

4 years ago

Quite welcome but don't thank me too much. I'm just the QA/Troubleshooter. Honktown did the code.

4 years ago

So I did a bunch of tests and I could not find any settings that gets the desired behavior. Setting the prototype to mineable=false has no effect. Setting the entity to mineable=false makes it so that it cannot be mined by hand, but mining drills can still mine it (if they can mine the appropriate category).

My old method was using a dummy fluid to mine. I forget why I stopped using that method specifically, but that might stop AAI from mining.

AAI miner will need to make some changes on their end to see if a resource ought to be mineable.

4 years ago
(updated 4 years ago)

Weird. I put in that code just as I pasted it and it worked exactly as it should?? I wonder why it isn't working for you.
Gonna re test it right now

4 years ago
(updated 4 years ago)

Yep. Just re-tested. Works exactly as expected with the code replacement I noted like 4 replies up.
Screenshot: https://www.dropbox.com/s/x6mwtkmzrk0i75e/working.png?raw=1
Copy of control.lua I am using: https://www.dropbox.com/s/7ycq6n86icypcjq/control.lua?dl=0

4 years ago

I was surprised that vanilla miners did not respect the minable flag. But it seems AAI Miners does. Using resource category and the flag together seems to give the desired results. Thanks for your interest.

4 years ago

I assume AAI miner follows the unminable flag because it can do weird stuff like mine ores with liquids as long as it has barrels of the liquid or mine oil as long as it has empty barrels to fill.

4 years ago

Thank you for the update and THANK YOU for the K2 oil fix.

New response