Item Network

by y_e_a_r

This mod adds a new logistics mechanic: The Item Network. It replaces trains and logistics bots by teleporting items and fluids directly between Network Chests and Tanks.

Tweaks
1 year, 1 month ago
1.1
2.19K
Logistics Fluids Logistic network Storage Cheats

b Crash attempt to index field '?' (a nil value)

9 months ago

Got this error today, trying to use a blueprint from another save.

3440.052 Error MainLoop.cpp:1391: Exception at tick 781393: The mod Item Network (0.8.4) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event item-network::on_nth_tick(1)
item-network/src/NetworkChest.lua:520: attempt to index field '?' (a nil value)
stack traceback:
item-network/src/NetworkChest.lua:520: in function 'update_network_chest'
item-network/src/NetworkChest.lua:677: in function <item-network/src/NetworkChest.lua:666>
(...tail calls...)
item-network/src/GlobalState.lua:611: in function 'update_queue'
item-network/src/NetworkChest.lua:724: in function 'update_queue'
item-network/src/NetworkChest.lua:785: in function <item-network/src/NetworkChest.lua:781>
3440.052 Error ServerMultiplayerManager.cpp:92: MultiplayerManager failed: "The mod Item Network (0.8.4) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event item-network::on_nth_tick(1)
item-network/src/NetworkChest.lua:520: attempt to index field '?' (a nil value)
stack traceback:
item-network/src/NetworkChest.lua:520: in function 'update_network_chest'
item-network/src/NetworkChest.lua:677: in function <item-network/src/NetworkChest.lua:666>
(...tail calls...)
item-network/src/GlobalState.lua:611: in function 'update_queue'
item-network/src/NetworkChest.lua:724: in function 'update_queue'
item-network/src/NetworkChest.lua:785: in function <item-network/src/NetworkChest.lua:781>"
3440.052 Info ServerMultiplayerManager.cpp:816: updateTick(781393) changing state from(InGame) to(Failed)
3440.052 Info SteamContext.cpp:538: Leaving lobby...
3450.844 Info ServerMultiplayerManager.cpp:154: Quitting multiplayer connection.
3450.844 Info ServerMultiplayerManager.cpp:816: updateTick(781393) changing state from(Failed) to(Closed)
3450.943 Info HttpSharedState.cpp:58: Downloading https://multiplayer.factorio.com/remove-game/16857509
3451.295 Info UDPSocket.cpp:233: Closing socket
3451.295 Info UDPSocket.cpp:263: Socket closed
3453.679 Quitting: user-quit.
3453.899 Steam API shutdown.
3453.902 Goodbye

9 months ago

Changed section to fix nil in src/NetworkChest.lua

-- get new sorted requests
local requests = {}
for _, request in ipairs(info.requests) do
if game.item_prototypes[request.item] ~= nil then -- Fix for nil 01/06/2024
local stack_size = game.item_prototypes[request.item].stack_size
local n_slots = math.ceil(request.buffer / stack_size)
local n_max = n_slots * stack_size
local old_count = contents[request.item] or 0
local new_count = math.min(n_max, old_count)
contents[request.item] = old_count - new_count
table.insert(requests, {
item = request.item,
sort_count = new_count - request.buffer,
buffer = request.buffer,
stack_size = stack_size,
count = new_count,
n_slots = n_slots,
})
end
end
table.sort(requests, request_list_sort)

7 months ago

Thanks for finding the fix and sorry for the delay. I'm working on a V2 that deprecates this code so I'm not planning on fixing this but the code you added seems correct. I'm not sure if this is correct, but this might happen if you add a request for a modded item and then remove the mod.

Did you do anything like this recently?

7 months ago

Yes, I figured that is what caused the error, so added my fix so it would not happen in the future.

New response