This doesn't look like it's applying to inserters and drills. I used this as my first experience with modding. ChatGPT helped.
My guess is that since there is no resource drain value on the normal entities, it never gets adjusted. I don't know about inserters yet.
I got the mining drills to work by adding this to the data.lua file. Now I'm working on inserters.
-- Retrieve the legendary quality from the quality table.
local legendary_quality = data.raw.quality["legendary"]
if not legendary_quality then
error("Legendary quality not found!")
end
-- Get the legendary drain multiplier.
local legendary_drain = legendary_quality.mining_drill_resource_drain_multiplier
if not legendary_drain then
error("Legendary mining_drill_resource_drain_multiplier not defined!")
end
-- Ensure that the "normal" quality (i.e. Common) is defined with the legendary drain.
-- This is important because burner mining drills (and other common devices)
-- default to using the "normal" quality for their resource drain values.
if data.raw.quality["normal"] then
data.raw.quality["normal"].mining_drill_resource_drain_multiplier = legendary_drain
log("Set 'normal' quality drain multiplier to legendary drain: " .. legendary_drain)
else
log("Normal quality not found!")
end
-- Update prototypes for all mining drills.
-- For regular drills we assume a natural drain of 1.0;
-- for the big mining drill, natural drain is 0.5.
for drill_name, drill in pairs(data.raw["mining-drill"] or {}) do
local natural_drain = 1.0
if drill.name == "big-mining-drill" then
natural_drain = 0.5
end
local new_drain = natural_drain * legendary_drain
drill.mining_drill_resource_drain_multiplier = new_drain
log("Set mining drill '" .. drill_name .. "' drain multiplier to " .. tostring(new_drain)
.. " (natural: " .. tostring(natural_drain) .. ", legendary: " .. tostring(legendary_drain) .. ")")
end
-- Update prototypes for all pumpjacks.
-- (Pumpjacks are assumed to have a natural drain of 1.0.)
for pumpjack_name, pumpjack in pairs(data.raw["pumpjack"] or {}) do
local new_drain = 1.0 * legendary_drain
pumpjack.mining_drill_resource_drain_multiplier = new_drain
log("Set pumpjack '" .. pumpjack_name .. "' drain multiplier to " .. tostring(new_drain)
.. " (natural: 1.0, legendary: " .. tostring(legendary_drain) .. ")")
end