entity.energy inserter
Posted: Thu Apr 17, 2014 2:37 pm
Could anybody explain how entity.energy works in case of inserter... I have tried to figure it out but I have no idea how its works.
Code: Select all
if glob.teleins.connections[k][1].heldstack == nil then
local energyConsumption = util.distance(glob.teleins.connections[k], glob.teleins.connections[k][1]) * basicEnergyCost
if glob.teleins.connections[k].energy > energyConsumption then --if inserter has enough energy
glob.teleins.connections[k].energy = glob.teleins.connections[k]-energyConsumption --drain energy
glob.teleins.connections[k][1].heldstack = {name = glob.teleins[k].heldstack.name, count = glob.teleins[k].heldstack.count}
glob.teleins[k].heldstack = nil
glob.teleins[k].active = true
end
end
But how to make new inserter that isn't display on player crafting page? ...here:FreeER wrote:make several inserters with different energy costs in the prototypes and then change the type of inserter (destroy old and replace with new inserter that has the appropriate energy cost) when it's output target distance changes (this only applies to the inserters that do the teleporting across a distance, not the ones that receive the items and place it down next to them, since the energy cost for that shouldn't actually change in-game).
This explains your results with movement/rotation consumption. As for manually increasing entity.energy, you can no longer increase it higher than it's buffer_capacity which at that time was 0 (which is shame...I used to do that when testing new machines and give them 100000000000 power lol)kovarex wrote:The buffer_capacity can be specified, but it is automatically set (overwriten) for some kind of entities:
Inserter, Mining Drill, Furnace, Assembling machine, Lab maybe some other.
The reason for this is, that the buffer is calculated to fit the needs of the machine (depending on speed and rotation/extension consumption for inserter, depending on modules for the rest).
For the particular usage (of the mod telelogistics). You can set the rotation/extension consumption higher or just drain the electricity for some time and store into a variable how much did you accumulate for the entity, once you have enough, you can make the needed transfer.
Anyway, as this is expected behavior I'm moving this to not a bug.
If you think that modders should be able to specify the buffer to not be overwritten in some cases, you can set it as modding interface request.
Hm, I think that the only item prototype needed for an inserter is for what is returned when you mine it, if I'm not forgetting something, then all you need to do there is make all of your teleinserters return the first teleinserter when they're mined (or if you create multiple power 'tiers' that require separate research then each would return the lowest from their tier).darius456 wrote:I was trying to create only entity prototype without item prototype but I have get an error message. (116550 its power in W, so its 116,55kW)