udf / factorio-auto-resource-redux

A factorio mod that automates most logistics so you can focus on combat
https://mods.factorio.com/mod/auto-resource-redux
MIT License
3 stars 4 forks source link

Mining Drill - add fluid #14

Open bengardner opened 6 months ago

bengardner commented 6 months ago

There is a comment about not being able to get the mining fluid easily. It references a 2017 forum post.

    -- there is no easy way to know what fluid a miner wants, the fluid is a property of the ore's prototype
    -- and the expected resources aren't simple to find: https://forums.factorio.com/viewtopic.php?p=247019
    -- so it will have to be done manually using the fluid access tank

However, the game has since added the entity.mining_target field. It is now rather easy to get the mining fluid.

Just for a demo, I added this print code.

function EntityHandlers.handle_mining_drill(o)
   ...
  if #o.entity.fluidbox > 0 then
    local target = o.entity.mining_target
    if target ~= nil then
      local dfluid = target.prototype.mineable_properties.required_fluid
      if dfluid ~= nil then
        print(("Drill @ %s requires %s"):format(serpent.line(o.entity.position), dfluid))
      end
    end

And see output like:

Drill @ {x = -239.5, y = -50.5} requires sulfuric-acid

I used that in the 'auto-configure requester tank' PR. #10

udf commented 6 months ago

Fascinating, apparently that field was added in 0.13.10. Guess I must've missed it when reading the docs.
There is the problem of the fluid temperature not mattering for mining drills, though (at least, I'm not seeing it in the mineable_properties table). So I think it makes sense to stick with fluid requesters (along with your auto config code), so that the temperature can be configured.