1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-11 14:49:24 +02:00

Autostash/Towny - fix that you couldn't insert to neutral chests

This commit is contained in:
Gerkiz 2022-10-22 22:16:21 +02:00
parent 57cdb64b69
commit ed9448725c
2 changed files with 15 additions and 26 deletions

View File

@ -208,6 +208,7 @@ end
local function on_init()
Autostash.insert_into_furnace(true)
Autostash.insert_to_neutral_chests(true)
Autostash.insert_into_wagon(true)
Autostash.bottom_button(true)
BottomFrame.reset()

View File

@ -14,6 +14,7 @@ local auto_stash_button_name = Gui.uid_name()
local this = {
floating_text_y_offsets = {},
whitelist = {},
insert_to_neutral_chests = false,
insert_into_furnace = false,
insert_into_wagon = false,
bottom_button = false,
@ -167,22 +168,17 @@ local function get_nearby_chests(player, a, furnace, wagon)
inventory_type = defines.inventory.cargo_wagon
end
for _, e in pairs(player.surface.find_entities_filtered({type = container_type, area = area, force = player.force})) do
local forces = player.force
if this.insert_to_neutral_chests then
forces = {player.force, 'neutral'}
end
for _, e in pairs(player.surface.find_entities_filtered({type = container_type, area = area, force = forces})) do
if ((player.position.x - e.position.x) ^ 2 + (player.position.y - e.position.y) ^ 2) <= r_square then
i = i + 1
containers[i] = e
end
end
if #containers <= 0 then
if is_mod_loaded('Krastorio2') then
for _, e in pairs(player.surface.find_entities_filtered({type = 'assembling-machine', area = area, force = player.force})) do
if ((player.position.x - e.position.x) ^ 2 + (player.position.y - e.position.y) ^ 2) <= r_square then
i = i + 1
containers[i] = e
end
end
end
end
sort_entities_by_distance(player.position, containers)
for _, entity in pairs(containers) do
@ -665,27 +661,19 @@ Gui.on_click(
)
function Public.insert_into_furnace(value)
if value then
this.insert_into_furnace = value
else
this.insert_into_furnace = false
end
this.insert_into_furnace = value or false
end
function Public.insert_into_wagon(value)
if value then
this.insert_into_wagon = value
else
this.insert_into_wagon = false
end
this.insert_into_wagon = value or false
end
function Public.bottom_button(value)
if value then
this.bottom_button = value
else
this.bottom_button = false
end
this.bottom_button = value or false
end
function Public.insert_to_neutral_chests(value)
this.insert_to_neutral_chests = value or false
end
function Public.set_dungeons_initial_level(value)