Loot Chest+

by hanes

Automagically collects all the loot, on all surfaces. Useful in combination with artillery. Convenient for mods that add loot when aliens die, like Bob's mods, Necromant, Reika's EndgameCombat, Alien Loot Economy and Alien Space Science. The chest acts now as a passive provider chest and gets unlocked with logistic-robotics tech.

Content
4 days ago
0.16 - 2.0
8.64K
Logistics Logistic network Storage

b [fixed] Crush on starting new game

4 years ago

Greetings, I'm the developer for Mobile Factory.

In Mobile Factory's control.lua, on_init() I do a for loop over all forces that already exist, and enable a technology. I do this for all forces because I don't know what force the players will be on for different mods/scenarios. In Loot Chest +, you assume the research was finished because there were players on the force... well I think I complete a research for forces before the player had a chance to join one, therefore player one either doesn't exist yet, or doesn't have a force or something weird. Adding a nil-check to make sure player one exists, or using the proper event force (event.research.force) would fix it. A simple way would be to add "force" as an argument for auto_cons_check, and use that directly instead of attempting to grab a player (if force is ~= nil from the argument).

4 years ago

Hi Honktown, I knew that part would be up for trouble some day. I once messed around with it, all blew up and I didn't touch it since. Also I'm not playing/modding much lately. But if you already have a working fix, I would add it.

4 years ago
(updated 4 years ago)

Trying to show this properly...

-- Check if automated construction is researched and change auto_cons_researched to true if so.
function auto_cons_check (force)
    if force then
        if force.technologies["logistic-robotics"].researched then
            auto_cons_researched = true
        end
    elseif game.players[1] and game.players[1].force.technologies["logistic-robotics"].researched then
        auto_cons_researched = true
    end
end

--                              *** Scripts ***

--Check if automated construction is researched when a research is finished
script.on_event(defines.events.on_research_finished, function(event)
    auto_cons_check(event.research.force)
end)

It's probably not 100% accurate to what you'd like to happen all the time, but it A) avoids the bug and B) adds safety if there's not a player 1 but there is player 2 or something. It'll do the old stuff but prevent the new bug.

Edit: I had to check if calling that with no argument was an error, lol. Some base game functions cause errors if you miss an argument

4 years ago

Is now added in 1.2.5. Thanks for helping out, much appreciated :)

New response