Logistic Carts

by dorfl

Carts (mini cars) carry items around a network of painted paths.

Content
3 years ago
0.16 - 1.1
1.81K
Logistics

g How to get energy into the electric carts?

24 days ago

See title

24 days ago

Ah ok. I see in the lua code that you need batteries in the cars equipment grid.

if car.name == CAR_ELECTRIC then

    fueled = car.grid.available_in_batteries >= CAR_CONSUMPTION_ELECTRIC
    local equipment = car.grid.equipment

    consume = function()
        local energy = CAR_CONSUMPTION_ELECTRIC
        for i = 1,#equipment,1 do
            local battery = equipment[i]

            if battery.prototype.type == "battery-equipment" and battery.energy > 0 then
                local take = min(energy, battery.energy)
                battery.energy = battery.energy - take
                energy = energy - take
            end

            if energy <= 0 then
                break
            end
        end
    end
end

New response