[0.12.5] LuaEntity.logistic_network function/value

This subforum contains all the issues which we already resolved.
Post Reply
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

[0.12.5] LuaEntity.logistic_network function/value

Post by Choumiko »

Started messing with the new LogisticNetwork/Cell API and found either a bug or a mistake in the Wiki for LuaEntity

WIki says LuaEntity.logistic_network is the network the entity is in or nil.
Trying it in code, with the entity being a (modded) wooden chest it complained being a function when i tried to get the item count of an item in the network.

Code: Select all

local logisticsNetwork = origEntity.logistic_network
--snip
logisticsNetwork.get_item_count(module) > 0 -- error here (and crash afterwards)
I then tried using it as a function with sth. like

Code: Select all

local logisticsNetwork = origEntity.logistic_network(origEntity.position, origEntity.force.name)
Tried different parameters; surface.name, surface/force only etc. Resulting in LuaEntity doesn't contain player (or nauvis if using surface.name)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.12.5] LuaEntity.logistic_network function/value

Post by Rseding91 »

Thanks for the report. This is now fixed for 0.12.6.
If you want to get ahold of me I'm almost always on Discord.

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: [0.12.5] LuaEntity.logistic_network function/value

Post by Choumiko »

Thanks for the fix, but:
Is it intended that it only returns a logistic network when called on a roboport? At least it should work for logistic chests and smart inserters, if not for every entity.

Code: Select all

/c game.player.print(serpent.dump(game.player.selected.logistic_network))
Above is only not nil for roboports, nil for logistics chests (and everything else) directly next to a roboport and everything else.

I'd expect the result to be the equivalent of using:

Code: Select all

local logisticsNetwork = entity.surface.find_logistic_network_by_position(entity.position, entity.force.name)

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.12.5] LuaEntity.logistic_network function/value

Post by kovarex »

Good point. Yes it worked only for roboports, but now (0.12.7) it works also for other entities (inserter/Character/logistic chests)

Post Reply

Return to “Resolved Problems and Bugs”