g Fluid amount has to be positive

3 years ago

534.364 Error MainLoop.cpp:1285: Exception at tick 215400: The mod Aquarium (0.1.9) caused a non-recoverable error.
Please report this error to the mod author.

Got this, no other mods present:

Error while running event Aquarium::on_tick (ID 0)
Fluid amount has to be positive.
stack traceback:
[C]: in function 'newindex'
__Aquarium
/control.lua:38: in function <Aquarium/control.lua:14>

3 years ago

I got this same error also. I opened "Aquarium_0.1.9.zip" and edited the file "\Aquarium-master\control.lua" and haven't seen the error since. The changes I made are as follows:

Changed line 25 from:
if f and f.name == "fish-water" and f.amount > 0.99 then
To:
if f and f.name == "fish-water" and f.amount >= 1 then

Changed line 33 from:
while amount > 0.99 do
To:
while amount >= 1 do

Inserted the following 3 lines as an error-check/trap (this is probably an unnecessary step) after line 35:
if amount < 0 then
amount = 0
end

Just for clarification, the entire "ticker = function(event)" section (Lines 14 through 54 inclusive) now looks like this:

ticker = function(event)
    if event.tick % 120 == 0 then
        if not global.ents or #global.ents == 0 then
            -- rehash table just in cases - the extra s is for 'sausage'
            if global.ents then global.ents = {} end
            script.on_event(defines.events.on_tick, nil)
        else
            for i, ent in next, global.ents do
                if ent.e and ent.e.valid and ent.e.fluidbox then
                    for k = 1, #ent.e.fluidbox do
                        local f = ent.e.fluidbox[k]
                        if f and f.name == "fish-water" and f.amount >= 1 then
                            local amount = f.amount
                            local tiles = ent.e.surface.get_connected_tiles(ent.pos, acceptableLivingConditions)
                            if type(tiles) ~= "table" or #tiles == 0 then
                                game.print({"fishyfishyfishy.wtf"})
                                table.remove(global.ents, i)
                                ent.e.destroy()
                            else
                                while amount >= 1 do
                                    PUTFISHLOL(ent.e.surface, tiles)
                                    amount = amount - 1
                                        if amount < 0 then
                                            amount = 0
                                            end
                                end
                                f.amount = math.max(amount, 0)
                                ent.e.fluidbox[k] = f
                                break
                            end
                        end
                    end
                else
                    -- Yes, we skip out early if we remove mid-table. #care
                    table.remove(global.ents, i)
                end
            end
        end
    end
end

end

New response