Page 1 of 1

Nanobots 2.0 v3.3.1 throwing numerous errors

Posted: Sat Jan 18, 2025 7:25 pm
by Cobalt Praetorian
This mod does not appear to be maintained at this point - or the maintainer is too busy for it, which I totally understand.

However, the mod is a massive QoL upgrade for me and I'm not sure I could play the game without it... and yet, there are several problems with the current version of it (itself a fork to update the mod for Space Age). With these constant errors spamming the message block (especially the second one, which doesn't stop spamming), I've had to turn off the mods, which is... not great. At least Error 1 only comes up every five minutes or so. Anyone have any ideas?

Error 1:
Script @stdlib2/stdlib/core.lua:45: Nanobots2:LuaConstantCombinatorControlBehavior doesn't contain key parameters.
From core.lua (lines 40-51):

Code: Select all

--- Prints and logs the msg
-- @tparam string msg
-- @treturn boolean true if the message was printed to someone
function Core.log_and_print(msg)
if game and #game.connected_players > 0 then
log(script.mod_name .. ':' .. msg)
game.print(msg)
return true
else
log(msg)
end
end
Error 2:
attempt to index local 'prototype' (a nil value)
Relevant code (I think?):

Code: Select all

local _find_item = function(simple_stack, _, player, at_least_one)
    local item, count = simple_stack.name, simple_stack.count
    count = at_least_one and 1 or count
    local prototype = prototypes.item[item]
    if prototype.type ~= 'item-with-inventory' then
        if player.cheat_mode or player.get_item_count(item) >= count then
            return true
        else
            local vehicle = player.vehicle
            local train = vehicle and vehicle.train --- @type LuaTrain
            return vehicle and ((vehicle.get_item_count(item) >= count) or (train and train.get_item_count(item) >= count))
        end
    end
end

Re: Nanobots 2.0 v3.3.1 throwing numerous errors

Posted: Sun Jan 19, 2025 4:50 am
by Silari
The second one is probably breaking because of the

Code: Select all

local prototype = prototypes.item[item]
line. Not every item stack is going to be of type item, some will be a tool or a module. You MIGHT be able to fix it by changing it to

Code: Select all

local prototype = prototypes.item[item] or prototypes.tool[item] or prototypes.tool[module]
if I'm remembering how LUA and the prototypes work. There might be a couple of other item types which aren't in the item category, but can't think of any off the top of my head.