Brave New Assembling Machines


This mod adds three assembling machines that are larger, can make fluid items, and are a host selectable speed

Content
a month ago
1.1 - 2.0
1.77K
Manufacturing

g Problems after update 2.0.6

9 months ago

Error that pops up when I mine the machine.

Error while running event brave-new-assembling-machines::on_player_mined_entity (ID 69)
brave-new-assembling-machines/control.lua:159: bad argument #1 of 2 to 'pairs' (table expected, got nil)
stack traceback:
[C]: in function 'pairs'
brave-new-assembling-machines/control.lua:159: in function 'process_mined_entity'
brave-new-assembling-machines/control.lua:175: in function <brave-new-assembling-machines/control.lua:173>

8 months ago

Can you post a log ?

8 months ago

From this code location I can tell you are picking up an assembling machine 5 or 6, (cyan or green) and the event says there was no assembling machine being tracked. I could put a safeguard around this, but wondering how this occurred ?

Thanks for the report !

8 months ago

The cause may be due to a race condition where you picked it up JUST as it was about to explode. Looking into this further.

8 months ago

I tried to recreate this but was unable. But obviously there is some race condition that could cause this, so I put a safeguard into 2.0.7. I'll wait for a reply from you before posting since I think it is a very rare situation that could cause it.

8 months ago
(updated 8 months ago)

Everything works fine for me with version 2.0.5, it's the update to version 2.0.6 that's causing the problem.
I don't have explosions enabled, so I'm guessing that's the problem.
I'm getting the error on mined machine 6.

8 months ago

Right - so without a log file I'll need a bunch of questions:
What mods are you running?
Are you running Space Age ?
Is this occurring every time or only once, is it reproduceable?
in game you can list all the mods with:
/c for name in pairs(script.active_mods) do game.print(name) end

8 months ago
(updated 8 months ago)

Firstly, I use a lot of mods, and secondly, I have Space Age.
This is bound to happen after updating to 2.0.6, just realised it doesn't matter if you're building or mine.

I'm uploading the logs now, hold on a second.

https://drive.google.com/drive/folders/18nZkxqIEDO0iJS4-oJLTDOCwtHfI25zI?usp=sharing

8 months ago
(updated 8 months ago)

I tested building a new game with existing mods and found no problems.
Any problems with old saves? Need to migrate?

I have a feeling you need
on_configuration_changed

8 months ago

Well, I've established that it's because you changed the value of storage, but the old save is still the same value as before, and script.on_init only takes effect when building a new game.

You probably do need to migrate the script to make the change to support the old save.

8 months ago

Great info - thanks !

8 months ago

do ya think this will handle it ?

--=================================================================================================
script.on_event(defines.events.on_player_created, function(event)
    storage.scenario_version = script.active_mods["brave-new-assembling-machines"]
end)

--=================================================================================================
script.on_configuration_changed(function(chgdata)
    local new = script.active_mods["brave-new-assembling-machines"]
    if new ~= nil then
        local old = storage.scenario_version
        if old ~= new then
            game.reload_script()
            storage.scenario_version = new
        end
    end
 end)
8 months ago

-- On Init - only runs once the first
-- time the game starts


script.on_init(function(event)
storage.ocfg = {}
storage.ocfg.notify_assembler_explode_notification = {} -- players
storage.ocfg.assembler_explodes = true
storage.ocfg.surface_index = 1
storage.ocfg.assembling_machine = {}
end)


script.on_load(function(event)
end)


script.on_configuration_changed(function(event)
if storage.ocfg then
if storage.ocfg.bno_assembler_explodes ~= nil then
storage.ocfg.assembler_explodes = storage.ocfg.bno_assembler_explodes
storage.ocfg.bno_assembler_explodes = nil
end
if storage.ocfg.assembling_machine_bno ~= nil then
storage.ocfg.assembling_machine = storage.ocfg.assembling_machine_bno
storage.ocfg.assembling_machine_bno = nil
end
end
end)


script.on_event(defines.events.on_player_joined_game, function(event)
if (not script.active_mods["brave-new-oarc"]) and #game.forces[event.player_index].players < 1 then
game.players[event.player_index].force.share_chart = true -- this should be on by default for every player. BNO enables turning it on/off
end
end)

8 months ago

The solution given by Copilot AI, which I added within the code, does solve the existing problem.
There should be a better way, but I really don't know much about it either.

8 months ago

Which copilot are you using?
OK - so rename of a variable was not handled - shit. It probably belongs in a migrate script - but this will work too, much appreciated !

8 months ago

I reviewed the changes - you are 100% correct and your solution is perfect. Thank you, I'll do some quick tests tomorrow using an 2.0.5 version and test the port to 2.0.7 to verify we're good. Sorry for the issues, and I do appreciate your help on this - check the change log for a mention!

New response