Can't figure out how to mod existing Inserter power use

Place to get help with not working mods / modding interface.
Post Reply
Peter34
Smart Inserter
Smart Inserter
Posts: 1100
Joined: Mon Nov 10, 2014 12:44 pm
Contact:

Can't figure out how to mod existing Inserter power use

Post by Peter34 »

After making the very quick and super-simple mod to make it take more time to craft the Pipe-to-Ground (5s instead of 0.5s), with some help, I've decided to tackle a comparatively much more ambitious project:

I want to re-balance the existing Inserters in the game, so as to reduce the prevalence of Fast Inserter use. I used to unthinkingly just always use those myself, until I started using the Inserter Energy Rebalance mod. But I'm not entirely happy with that mod, I'd rather make my own (note also that I'm not touching Burner Inserters - those are scary weird, I'm worried about breaking something, and honestly I think they work fine as they are).

My approach is three-fold:
1. Increase the crafting time of higher-tier Inserters. Normal Inserters take 1s, not 0.5, Long ones take 2s, then 3s for Fast Inserters and 4s for Smart Inserters.
2. Add a fractional Steel cost to Long Inserters and Smart Inserters.
3. Increase the power use and the drain of Fast Inserters and Smart Inserters (and Long Inserters too).

I've accomplished items #1 and #2 above just fine, but #3 confounds me.

Here is the mode code that works:

Code: Select all

data.raw.recipe["basic-inserter"].energy_required = 1

data.raw.recipe["science-pack-2"].ingredients =
    {
      {"basic-inserter", 1},
      {"basic-transport-belt", 2}
    }
data.raw.recipe["science-pack-2"].energy_required = 12
data.raw.recipe["science-pack-2"].result_count =2

data.raw.recipe["long-handed-inserter"].energy_required = 10
data.raw.recipe["long-handed-inserter"].ingredients =
    {
      {"iron-gear-wheel", 5},
      {"iron-plate", 4}, {"steel-plate",1},{"basic-inserter",5}
    }
data.raw.recipe["long-handed-inserter"].result_count =5

data.raw.recipe["fast-inserter"].energy_required = 6
data.raw.recipe["fast-inserter"].ingredients =
    {
      {"iron-plate", 3}, {"steel-plate",1}, {"basic-inserter",2}, {"electronic-circuit", 4}
    }
data.raw.recipe["fast-inserter"].result_count = 2

data.raw.recipe["smart-inserter"].energy_required = 4
data.raw.recipe["smart-inserter"].ingredients =
    {
     {"electronic-circuit", 4} ,{"fast-inserter",1}
    }
data.raw.recipe["smart-inserter"].result_count = 1

data.raw.recipe["science-pack-3"].ingredients =
    {
      {"smart-inserter", 1},
      {"steel-plate", 2}, {"battery", 3}, {"advanced-circuit", 3}    }
data.raw.recipe["science-pack-3"].energy_required = 30
data.raw.recipe["science-pack-3"].result_count = 3
It does the first 2 things on my list, and as far as I can see it does it very well. It makes Long/Smart Inserters be crafted in "batches" instead of 1 at a time, and to compensate it also tweaks the cost of Green/Blue Magic Science Potions.

The problem is the energy usage.

I've tried to add more to the section on Fast Inserters, so that it reads like this:

Code: Select all

data.raw.recipe["fast-inserter"].energy_required = 6
data.raw.recipe["fast-inserter"].ingredients =
    {
      {"iron-plate", 3}, {"steel-plate",1}, {"basic-inserter",2}, {"electronic-circuit", 4}
    }
data.raw.recipe["fast-inserter"].result_count = 2
data.raw.entity["long-handed-inserter"].energy_per_movement = 6000
data.raw.entity["long-handed-inserter"].energy_per_rotation = 6000
But then I get an error message, when trying to start Factorio, something to do with a "nil" value. Confusingly, Factorio claims the error occurs in line 18, which is multiple lines after the new stuff I've inserted. But when I delete the 2 added lines again, the error stops happening and Factorio works fine.

So, basically, I don't know what I'm doing. I suspect that it's wrong of me to use data.raw.entity, or perhaps it's wrong to use the energy_per_movement and energy_per_rotation and I should use something else instead. Or perhaps the problem is caused by me stating the energy in joules (or watts although that would be wrong physics) and the game expects me to state them in kilos (or even megas) instead, although I found the energy_per_movement/rotation thing in the game's data files and its "field value" or whatever it's called was expressed in thousands, thus presumably in joules.

My hunch is that the error is indeed the entity thing, but I have no clue what it should be instead of data.raw.entity["entity-name].*

User avatar
oLaudix
Filter Inserter
Filter Inserter
Posts: 282
Joined: Sun Jun 14, 2015 3:24 pm
Contact:

Re: Can't figure out how to mod existing Inserter power use

Post by oLaudix »

Power consumed by inserter is also based on its speed. Tbh power consumed changed only when i was fiddeling with speed and power drain.
Image

Peter34
Smart Inserter
Smart Inserter
Posts: 1100
Joined: Mon Nov 10, 2014 12:44 pm
Contact:

Re: Can't figure out how to mod existing Inserter power use

Post by Peter34 »

so you're saying that it's not possible to modify Inserter power usage?

Can I modify their Drain?

Post Reply

Return to “Modding help”