AmmoLoader 2.1


Fork of Ammo Loader+ (https://mods.factorio.com/mod/ammo-loader by SilentCrim). Only updated for Factorio 2.1 compatibility — no new features. Storage chests that automatically load turrets and vehicles with ammo and fuel.

Content
3 months ago
2.1
454

b on_configuration_changed LuaItemPrototype doesn't contain key fuel_category.

a month ago

Hi, I’m using version 2.1.20 (experimental) of Factorio and I’m getting the error below when loading my save file.
Up to version 2.1.19, there were no problems.

Error while running event ammoloader21::on_configuration_changed
LuaItemPrototype doesn't contain key fuel_category.
stack traceback:
[C]: in function 'index'
__ammoloader21
/lib/ItemDB.lua:265: in function 'newFuel'
ammoloader21/lib/ItemDB.lua:44: in function 'init'
__ammoloader21
/lib/Initializer.lua:73: in function 'doInit'
ammoloader21/lib/Version.lua:29: in function <ammoloader21/lib/Version.lua:23>

a month ago
(updated a month ago)

in mod:
in file ammoloader21/lib/ItemDB.lua in the line 265
change obj.category = proto.fuel_category to obj.category = proto.fuel_categories
save
test

a month ago

Исправил с ИИ: https://TransFiles.ru/tgs05

a month ago

Hi and thank you for your reply, but the error now concerns fuel_categories
Error whilst running the event ammoloader21::on_configuration_changed
LuaItemPrototype does not contain the key fuel_categories.
Stack traceback:
[C]: in function “index”
__ammoloader21
/lib/ItemDB.lua:265: in function 'newFuel'
ammoloader21/lib/ItemDB.lua:44: in function “init”
__ammoloader21
/lib/Initializer.lua:73: in function “doInit”
ammoloader21/lib/Version.lua:29: in function <ammoloader21/lib/Version.lua:23>

3 days ago

Mod-ul AmmoLoader 2.1 (2.2.1) a cauzat o eroare iremediabilă.
O eroare similara

Error while running event ammoloader21::on_init()
LuaItemPrototype doesn't contain key fuel_category.
stack traceback:
[C]: in function 'index'
__ammoloader21
/lib/ItemDB.lua:265: in function 'newFuel'
ammoloader21/lib/ItemDB.lua:44: in function 'init'
__ammoloader21
/lib/Initializer.lua:73: in function 'doInit'
ammoloader21/lib/Handlers.lua:389: in function <ammoloader21/lib/Handlers.lua:387>

3 days ago
(updated 3 days ago)

Данную проблему у себя я решил с помощью смекалки и нейросети)
Идем по адресу: С/Пользователи/Имя пользователя/Appdata/Roaming/Factorio/mods
Находим архив ammoloader21_2.2.1 и открываем его (НЕ РАСПАКОВЫВАЕМ!)
Далее идем в папку ammoloader21 далее lib и находим файл ItemDB.lua и извлекаем его в любое удобно место.
Открываем данный файл блокнотом и ищем 2 блока кода function ItemDB.fuelCats и function ItemDB.newFuel(proto)
В блоке function ItemDB.fuelCats меняем весь блок на следующее:

function ItemDB.fuelCats(prototype)
local res = {}

if prototype and prototype.fuel_categories then
    for catName, cat in pairs(ItemDB.cats()) do
        if prototype.fuel_categories[catName] then 
            res[catName] = cat 
        end 
    end
end

return res

end

Далее ищем блок function ItemDB.newFuel(proto) и меняем весь блок на это:

function ItemDB.newFuel(prototype)
if not prototype then return nil end

local fuel_cat = nil
if prototype.fuel_categories then
    fuel_cat = next(prototype.fuel_categories)
end

if not fuel_cat then return nil end

local res = {
    name = prototype.name,
    fuel_category = fuel_cat,
    fuel_value = prototype.fuel_value,
    emissions_multiplier = prototype.fuel_emissions_multiplier or 1.0,
}

return res

end

Сохраняем изменения и закидываем этот файл обратно в архив из которого мы его извлекли с ЗАМЕНОЙ!
После данной процедуры у меня мод полностью заработал ошибок и вылетов нет)
Автору форка: по возможности обнови мод с данными изменениями мне не жалко^^

New response