Rampant, fixed


Based on Rampant 1.1.1 (new AI and enemies). - New types of enemies - Works on SA planets, can control biters, demolishers, Gleba units - Can mutate existing nests - Can attack from afar - Improved search for a passage in the defense - Some new mechanics

Content
2 days ago
1.1 - 2.0
44.5K
Enemies

b Combat powerup

6 months ago

Sometimes happens on shooting or end of powerup:

The mod Rampant, fixed (2.0.8) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event RampantFixed::on_player_ammo_inventory_changed (ID 42)
RampantFixed/libs/Powerup.lua:35: attempt to index field '?' (a nil value)
stack traceback:
RampantFixed/libs/Powerup.lua:35: in function 'restoreAmmo'
RampantFixed/libs/Powerup.lua:77: in function 'endlessAmmo_onInventoryChanged'
RampantFixed/control.lua:1314: in function
<RampantFixed/control.lua:1311>

6 months ago

Happens on end of magazine during powerup

The mod Rampant, fixed (2.0.8) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event RampantFixed::on_player_ammo_inventory_changed (ID 42)
RampantFixed/libs/Powerup.lua:35: attempt to index field '?' (a nil value)
stack traceback:
RampantFixed/libs/Powerup.lua:35: in function 'restoreAmmo'
RampantFixed/libs/Powerup.lua:77: in function 'endlessAmmo_onInventoryChanged'
RampantFixed/control.lua:1314: in function
<RampantFixed/control.lua:1311>

6 months ago

Unfortunately, I can't reproduce the error.
You're not the first to point out that it's possible with certain actions, but I need a save in which I can reproduce it

6 months ago

The exact conditions are unknown, although it always happens when the magazine amount changes (not internal magazine ammo).
Multiplayer seems to give more frequent crashes but that may be just an observation error.
Fix was actually developed by me and my friend, in libs/powerup.lua around line 25, func powerup.restoreAmmo:

function powerup.restoreAmmo(player, powerupSettings)
local ammoData = powerupSettings["ammo"]
if not ammoData then
return false
end

local character_ammo = player.get_inventory(defines.inventory.character_ammo)
if not character_ammo then
    return false
end

local ammoRestored = false
-- Only iterate up to the smaller of the two arrays
local maxIndex = math.min(#character_ammo, #ammoData)

for i = 1, maxIndex do
    -- Check if the current inventory slot is valid
    if character_ammo[i].valid_for_read then
        -- Make sure ammoData[i] exists before trying to access it
        if ammoData[i] and ammoData[i].name == character_ammo[i].name then
            if (character_ammo[i].count+1) == ammoData[i].count then
                character_ammo[i].count = ammoData[i].count
                ammoRestored = true
                break
            end
        end
    end
end

return ammoRestored

end

You basically want to check if ammoData[i] even exists, because for some unknown for me reason it can be empty.
Also its good if you just iterate to the smaller index rather than simply character_ammo, and this also can be one of the reasons it crashes.
If you need further explaination or just around-help you can add me on dc: donhui5680

6 months ago

The idea that the error is not caused by the player's inventory, but by its saved image didn't occur to me

Thank you

6 months ago

Sometimes happens on shooting or end of powerup:

The mod Rampant, fixed (2.0.8) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event RampantFixed::on_player_ammo_inventory_changed (ID 42)
RampantFixed/libs/Powerup.lua:35: attempt to index field '?' (a nil value)
stack traceback:
RampantFixed/libs/Powerup.lua:35: in function 'restoreAmmo'
RampantFixed/libs/Powerup.lua:77: in function 'endlessAmmo_onInventoryChanged'
RampantFixed/control.lua:1314: in function
<RampantFixed/control.lua:1311>

+1. But in: The mod Rampant, fixed (2.0.9)

6 months ago

Sometimes happens on shooting or end of powerup:

The mod Rampant, fixed (2.0.8) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event RampantFixed::on_player_ammo_inventory_changed (ID 42)
RampantFixed/libs/Powerup.lua:35: attempt to index field '?' (a nil value)
stack traceback:
RampantFixed/libs/Powerup.lua:35: in function 'restoreAmmo'
RampantFixed/libs/Powerup.lua:77: in function 'endlessAmmo_onInventoryChanged'
RampantFixed/control.lua:1314: in function
<RampantFixed/control.lua:1311>

+1. But in: The mod Rampant, fixed (2.0.9):
The mod Rampant, fixed (2.0.9) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event RampantFixed::on_player_ammo_inventory_changed (ID 42)
RampantFixed/libs/Powerup.lua:35: attempt to index field '?' (a nil value)
stack traceback:
RampantFixed/libs/Powerup.lua:35: in function 'restoreAmmo'
RampantFixed/libs/Powerup.lua:77: in function 'endlessAmmo_onInventoryChanged'
RampantFixed/control.lua:1314: in function <RampantFixed/control.lua:1311>

6 months ago

https://mods.factorio.com/mod/m-rpg_items
Also this mod was in game. And error begin, when i buy "uranium magazie" item in shop.. After load a save game i can play and 5 min, and 15 sec, and 1 hour, and see this error....

New response