Page 1 of 1

[0.12.5] LuaEntity.logistic_network function/value

Posted: Sun Aug 30, 2015 1:38 pm
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)

Re: [0.12.5] LuaEntity.logistic_network function/value

Posted: Sun Aug 30, 2015 4:00 pm
by Rseding91
Thanks for the report. This is now fixed for 0.12.6.

Re: [0.12.5] LuaEntity.logistic_network function/value

Posted: Wed Sep 02, 2015 10:00 am
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)

Re: [0.12.5] LuaEntity.logistic_network function/value

Posted: Wed Sep 02, 2015 10:31 am
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)