Brave New World

by wadsaek

RTS-like scenario for Factorio. Player character is removed, all work must be done by bots. Fork of the already existing port of Brave New World by candidae, originally ported by Sladki and published by Omnifarious, now ported by wadsaek.

Scenarios
4 months ago
2.0
265

g For Anyone having the Problem with crash on changing Machine Recipe

18 days ago

Hi Guys,
if anyone of you has the same problem as me, getting a crash on changing the machine recipes with the spill_item_stack function in the dropItems function, while there are some ingredients still in the machine.
I fixed it for myself but since i am not the author of this mod i can t change it on the mod itself.
If you need a fix, u need to change the dropItems function in the control lua file.
Best way is to unzip the mod to a folder and replace the dropItems function in line 94 with the function on the end.
Then Zip the full mod folder again and put into your mods folder for factorio.

local function dropItems(player, name, count)
local entity = player.opened or player.selected
local inserted = 0
if entity and entity.insert then
for _, inventory_id in pairs(defines.inventory) do
local inventory = entity.get_inventory(inventory_id)
if inventory then
local barpos = inventory.supports_bar() and inventory.get_bar() or nil
if inventory.supports_bar() then
inventory.set_bar()
end
local just_inserted = inventory.insert{name = name, count = count}
inserted = inserted + just_inserted
count = count - just_inserted
if inventory.supports_bar() then
inventory.set_bar(barpos)
end
if count <= 0 then break end
end
end
if count > 0 then
count = count - entity.insert({name = name, count = count})
end
end
if count > 0 then
local pos = (entity and entity.valid) and entity.position or player.position
local surface = (entity and entity.valid) and entity.surface or player.surface
local force = (entity and entity.valid) and entity.force or player.force
surface.spill_item_stack{
position = pos,
stack = {name = name, count = count},
enable_looted = false,
force = force,
allow_belts = true
}
end
end

New response