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

Merge branch 'develop' into develop

This commit is contained in:
Gerkiz 2021-07-26 21:55:42 +02:00 committed by GitHub
commit 8da00da125
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 146 additions and 146 deletions

View File

@ -212,7 +212,7 @@ local function on_player_ammo_inventory_changed(event)
if this.enable_capsule_cursor_warning then if this.enable_capsule_cursor_warning then
local nukes = player.remove_item({name = 'atomic-bomb', count = 1000}) local nukes = player.remove_item({name = 'atomic-bomb', count = 1000})
if nukes > 0 then if nukes > 0 then
Utils.action_warning('{Nuke}', player.name .. ' tried to equip nukes but was not trusted.') Utils.action_warning('[Nuke]', player.name .. ' tried to equip nukes but was not trusted.')
damage_player(player) damage_player(player)
end end
end end
@ -342,7 +342,7 @@ local function on_player_used_capsule(event)
return return
end end
local prefix = '{Capsule}' local prefix = '[Capsule]'
msg = format(player.name .. ' damaged: %s with: %s', get_entities(name, entities), name) msg = format(player.name .. ' damaged: %s with: %s', get_entities(name, entities), name)
local ban_msg = format('Damaged: %s with: %s. This action was performed automatically. Visit getcomfy.eu/discord for forgiveness', get_entities(name, entities), name) local ban_msg = format('Damaged: %s with: %s. This action was performed automatically. Visit getcomfy.eu/discord for forgiveness', get_entities(name, entities), name)
@ -553,7 +553,7 @@ local function on_gui_opened(event)
end end
if player.name ~= corpse_owner.name then if player.name ~= corpse_owner.name then
Utils.action_warning('{Corpse}', player.name .. ' is looting ' .. corpse_owner.name .. '´s body.') Utils.action_warning('[Corpse]', player.name .. ' is looting ' .. corpse_owner.name .. '´s body.')
if not this.corpse_history then if not this.corpse_history then
this.corpse_history = {} this.corpse_history = {}
end end
@ -608,7 +608,7 @@ local function on_pre_player_mined_item(event)
return return
end end
if player.name ~= corpse_owner.name then if player.name ~= corpse_owner.name then
Utils.action_warning('{Corpse}', player.name .. ' has looted ' .. corpse_owner.name .. '´s body.') Utils.action_warning('[Corpse]', player.name .. ' has looted ' .. corpse_owner.name .. '´s body.')
if not this.corpse_history then if not this.corpse_history then
this.corpse_history = {} this.corpse_history = {}
end end
@ -688,7 +688,7 @@ local function on_player_cursor_stack_changed(event)
if ammo_names[name] then if ammo_names[name] then
local item_to_remove = player.remove_item({name = name, count = 1000}) local item_to_remove = player.remove_item({name = name, count = 1000})
if item_to_remove > 0 then if item_to_remove > 0 then
Utils.action_warning('{Capsule}', player.name .. ' equipped ' .. name .. ' but was not trusted.') Utils.action_warning('[Capsule]', player.name .. ' equipped ' .. name .. ' but was not trusted.')
damage_player(player) damage_player(player)
end end
end end
@ -716,7 +716,7 @@ local function on_player_cancelled_crafting(event)
player.character.die('player') player.character.die('player')
Utils.action_warning( Utils.action_warning(
'{Crafting}', '[Crafting]',
player.name .. player.name ..
' canceled their craft of item ' .. ' canceled their craft of item ' ..
event.recipe.name .. ' of total count ' .. crafting_queue_item_count .. ' in raw items (' .. crafted_items .. ' slots) but had no inventory left.' event.recipe.name .. ' of total count ' .. crafting_queue_item_count .. ' in raw items (' .. crafted_items .. ' slots) but had no inventory left.'
@ -778,7 +778,7 @@ local function on_permission_group_added(event)
local group = event.group local group = event.group
if group then if group then
Utils.log_msg('{Permission_Group}', player.name .. ' added ' .. group.name) Utils.log_msg('[Permission_Group]', player.name .. ' added ' .. group.name)
end end
end end
@ -794,7 +794,7 @@ local function on_permission_group_deleted(event)
local name = event.group_name local name = event.group_name
local id = event.id local id = event.id
if name then if name then
Utils.log_msg('{Permission_Group}', player.name .. ' deleted ' .. name .. ' with ID: ' .. id) Utils.log_msg('[Permission_Group]', player.name .. ' deleted ' .. name .. ' with ID: ' .. id)
end end
end end
@ -815,18 +815,18 @@ local function on_permission_group_edited(event)
action = k action = k
end end
end end
Utils.log_msg('{Permission_Group}', player.name .. ' edited ' .. group.name .. ' with type: ' .. event.type .. ' with action: ' .. action) Utils.log_msg('[Permission_Group]', player.name .. ' edited ' .. group.name .. ' with type: ' .. event.type .. ' with action: ' .. action)
end end
if event.other_player_index then if event.other_player_index then
local other_player = game.get_player(event.other_player_index) local other_player = game.get_player(event.other_player_index)
if other_player and other_player.valid then if other_player and other_player.valid then
Utils.log_msg('{Permission_Group}', player.name .. ' moved ' .. other_player.name .. ' with type: ' .. event.type .. ' to group: ' .. group.name) Utils.log_msg('[Permission_Group]', player.name .. ' moved ' .. other_player.name .. ' with type: ' .. event.type .. ' to group: ' .. group.name)
end end
end end
local old_name = event.old_name local old_name = event.old_name
local new_name = event.new_name local new_name = event.new_name
if old_name and new_name then if old_name and new_name then
Utils.log_msg('{Permission_Group}', player.name .. ' renamed ' .. group.name .. '. New name: ' .. new_name .. '. Old Name: ' .. old_name) Utils.log_msg('[Permission_Group]', player.name .. ' renamed ' .. group.name .. '. New name: ' .. new_name .. '. Old Name: ' .. old_name)
end end
end end
@ -839,7 +839,7 @@ local function on_permission_string_imported(event)
return return
end end
Utils.log_msg('{Permission_Group}', player.name .. ' imported a permission string') Utils.log_msg('[Permission_Group]', player.name .. ' imported a permission string')
end end
--- This is used for the RPG module, when casting capsules. --- This is used for the RPG module, when casting capsules.

View File

@ -176,20 +176,20 @@ local functions = {
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
game.permissions.get_group('Default').set_allows_action(defines.input_action.open_blueprint_library_gui, true) game.permissions.get_group('Default').set_allows_action(defines.input_action.open_blueprint_library_gui, true)
game.permissions.get_group('Default').set_allows_action(defines.input_action.import_blueprint_string, true) game.permissions.get_group('Default').set_allows_action(defines.input_action.import_blueprint_string, true)
get_actor(event, '{Blueprints}', 'has enabled blueprints!') get_actor(event, '[Blueprints]', 'has enabled blueprints!')
else else
game.permissions.get_group('Default').set_allows_action(defines.input_action.open_blueprint_library_gui, false) game.permissions.get_group('Default').set_allows_action(defines.input_action.open_blueprint_library_gui, false)
game.permissions.get_group('Default').set_allows_action(defines.input_action.import_blueprint_string, false) game.permissions.get_group('Default').set_allows_action(defines.input_action.import_blueprint_string, false)
get_actor(event, '{Blueprints}', 'has disabled blueprints!') get_actor(event, '[Blueprints]', 'has disabled blueprints!')
end end
end, end,
['comfy_panel_spaghett_toggle'] = function(event) ['comfy_panel_spaghett_toggle'] = function(event)
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
this.gui_config.spaghett.enabled = true this.gui_config.spaghett.enabled = true
get_actor(event, '{Spaghett}', 'has enabled spaghett mode!') get_actor(event, '[Spaghett]', 'has enabled spaghett mode!')
else else
this.gui_config.spaghett.enabled = nil this.gui_config.spaghett.enabled = nil
get_actor(event, '{Spaghett}', 'has disabled spaghett mode!') get_actor(event, '[Spaghett]', 'has disabled spaghett mode!')
end end
spaghett() spaghett()
end, end,
@ -225,10 +225,10 @@ local poll_function = {
['comfy_panel_poll_trusted_toggle'] = function(event) ['comfy_panel_poll_trusted_toggle'] = function(event)
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
this.gui_config.poll_trusted = true this.gui_config.poll_trusted = true
get_actor(event, '{Poll Mode}', 'has disabled non-trusted people to do polls.') get_actor(event, '[Poll Mode]', 'has disabled non-trusted people to do polls.')
else else
this.gui_config.poll_trusted = false this.gui_config.poll_trusted = false
get_actor(event, '{Poll Mode}', 'has allowed non-trusted people to do polls.') get_actor(event, '[Poll Mode]', 'has allowed non-trusted people to do polls.')
end end
end, end,
['comfy_panel_poll_no_notify_toggle'] = function(event) ['comfy_panel_poll_no_notify_toggle'] = function(event)
@ -247,10 +247,10 @@ local antigrief_functions = {
local AG = Antigrief.get() local AG = Antigrief.get()
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
AG.enabled = true AG.enabled = true
get_actor(event, '{Antigrief}', 'has enabled the antigrief function.', true) get_actor(event, '[Antigrief]', 'has enabled the antigrief function.', true)
else else
AG.enabled = false AG.enabled = false
get_actor(event, '{Antigrief}', 'has disabled the antigrief function.', true) get_actor(event, '[Antigrief]', 'has disabled the antigrief function.', true)
end end
trust_connected_players() trust_connected_players()
end end
@ -262,10 +262,10 @@ local fortress_functions = {
local Module = Fullness.get() local Module = Fullness.get()
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
Module.fullness_enabled = true Module.fullness_enabled = true
get_actor(event, '{Fullness}', 'has enabled the inventory fullness function.') get_actor(event, '[Fullness]', 'has enabled the inventory fullness function.')
else else
Module.fullness_enabled = false Module.fullness_enabled = false
get_actor(event, '{Fullness}', 'has disabled the inventory fullness function.') get_actor(event, '[Fullness]', 'has disabled the inventory fullness function.')
end end
end, end,
['comfy_panel_offline_players'] = function(event) ['comfy_panel_offline_players'] = function(event)
@ -273,10 +273,10 @@ local fortress_functions = {
local Module = WPT.get() local Module = WPT.get()
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
Module.offline_players_enabled = true Module.offline_players_enabled = true
get_actor(event, '{Offline Players}', 'has enabled the offline player function.') get_actor(event, '[Offline Players]', 'has enabled the offline player function.')
else else
Module.offline_players_enabled = false Module.offline_players_enabled = false
get_actor(event, '{Offline Players}', 'has disabled the offline player function.') get_actor(event, '[Offline Players]', 'has disabled the offline player function.')
end end
end, end,
['comfy_panel_collapse_grace'] = function(event) ['comfy_panel_collapse_grace'] = function(event)
@ -284,10 +284,10 @@ local fortress_functions = {
local Module = WPT.get() local Module = WPT.get()
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
Module.collapse_grace = true Module.collapse_grace = true
get_actor(event, '{Collapse}', 'has enabled the collapse function. Collapse will occur after wave 100!') get_actor(event, '[Collapse]', 'has enabled the collapse function. Collapse will occur after wave 100!')
else else
Module.collapse_grace = false Module.collapse_grace = false
get_actor(event, '{Collapse}', 'has disabled the collapse function. You must reach zone 2 for collapse to occur!') get_actor(event, '[Collapse]', 'has disabled the collapse function. You must reach zone 2 for collapse to occur!')
end end
end, end,
['comfy_panel_spill_items_to_surface'] = function(event) ['comfy_panel_spill_items_to_surface'] = function(event)
@ -295,10 +295,10 @@ local fortress_functions = {
local Module = WPT.get() local Module = WPT.get()
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
Module.spill_items_to_surface = true Module.spill_items_to_surface = true
get_actor(event, '{Item Spill}', 'has enabled the ore spillage function. Ores now drop to surface when mining.') get_actor(event, '[Item Spill]', 'has enabled the ore spillage function. Ores now drop to surface when mining.')
else else
Module.spill_items_to_surface = false Module.spill_items_to_surface = false
get_actor(event, '{Item Spill}', 'has disabled the item spillage function. Ores no longer drop to surface when mining.') get_actor(event, '[Item Spill]', 'has disabled the item spillage function. Ores no longer drop to surface when mining.')
end end
end, end,
['comfy_panel_void_or_tile'] = function(event) ['comfy_panel_void_or_tile'] = function(event)
@ -306,10 +306,10 @@ local fortress_functions = {
local Module = WPT.get() local Module = WPT.get()
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
Module.void_or_tile = 'out-of-map' Module.void_or_tile = 'out-of-map'
get_actor(event, '{Void}', 'has changes the tiles of the zones to: out-of-map (void)') get_actor(event, '[Void]', 'has changes the tiles of the zones to: out-of-map (void)')
else else
Module.void_or_tile = 'lab-dark-2' Module.void_or_tile = 'lab-dark-2'
get_actor(event, '{Void}', 'has changes the tiles of the zones to: dark-tiles (flammable tiles)') get_actor(event, '[Void]', 'has changes the tiles of the zones to: dark-tiles (flammable tiles)')
end end
end, end,
['comfy_panel_trusted_only_car_tanks'] = function(event) ['comfy_panel_trusted_only_car_tanks'] = function(event)
@ -317,10 +317,10 @@ local fortress_functions = {
local Module = WPT.get() local Module = WPT.get()
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
Module.trusted_only_car_tanks = true Module.trusted_only_car_tanks = true
get_actor(event, '{Market}', 'has changed so only trusted people can buy car/tanks.', true) get_actor(event, '[Market]', 'has changed so only trusted people can buy car/tanks.', true)
else else
Module.trusted_only_car_tanks = false Module.trusted_only_car_tanks = false
get_actor(event, '{Market}', 'has changed so everybody can buy car/tanks.', true) get_actor(event, '[Market]', 'has changed so everybody can buy car/tanks.', true)
end end
end end
} }

View File

@ -660,7 +660,7 @@ function Public.save_car(ic, event)
log_err(ic, 'Owner of this vehicle is: ' .. p.name) log_err(ic, 'Owner of this vehicle is: ' .. p.name)
save_surface(ic, entity, p) save_surface(ic, entity, p)
Utils.action_warning('{Car}', player.name .. ' has looted ' .. p.name .. '´s car.') Utils.action_warning('[Car]', player.name .. ' has looted ' .. p.name .. '´s car.')
player.print('This car was not yours to keep.', Color.warning) player.print('This car was not yours to keep.', Color.warning)
local params = { local params = {
player = player, player = player,
@ -745,7 +745,7 @@ function Public.validate_owner(ic, player, entity)
if car.owner ~= player.index and player.driving then if car.owner ~= player.index and player.driving then
player.driving = false player.driving = false
if not player.admin then if not player.admin then
return Utils.print_to(nil, '{Car} ' .. player.name .. ' tried to drive ' .. p.name .. '´s car.') return Utils.print_to(nil, '[Car] ' .. player.name .. ' tried to drive ' .. p.name .. '´s car.')
end end
end end
end end

View File

@ -213,8 +213,10 @@ function Public.add_player_to_permission_group(player, group, forced)
locomotive_group.set_allows_action(defines.input_action.admin_action, false) locomotive_group.set_allows_action(defines.input_action.admin_action, false)
locomotive_group.set_allows_action(defines.input_action.drop_item, false) locomotive_group.set_allows_action(defines.input_action.drop_item, false)
locomotive_group.set_allows_action(defines.input_action.deconstruct, false) locomotive_group.set_allows_action(defines.input_action.deconstruct, false)
locomotive_group.set_allows_action(defines.input_action.activate_cut, false)
local default_group = game.permissions.get_group('Default') local default_group = game.permissions.get_group('Default')
default_group.set_allows_action(defines.input_action.deconstruct, false) default_group.set_allows_action(defines.input_action.deconstruct, false)
default_group.set_allows_action(defines.input_action.activate_cut, false)
end end
if not game.permissions.get_group('plebs') then if not game.permissions.get_group('plebs') then
@ -225,6 +227,7 @@ function Public.add_player_to_permission_group(player, group, forced)
plebs_group.set_allows_action(defines.input_action.add_permission_group, false) plebs_group.set_allows_action(defines.input_action.add_permission_group, false)
plebs_group.set_allows_action(defines.input_action.admin_action, false) plebs_group.set_allows_action(defines.input_action.admin_action, false)
plebs_group.set_allows_action(defines.input_action.deconstruct, false) plebs_group.set_allows_action(defines.input_action.deconstruct, false)
plebs_group.set_allows_action(defines.input_action.activate_cut, false)
end end
if not game.permissions.get_group('not_trusted') then if not game.permissions.get_group('not_trusted') then
@ -251,6 +254,7 @@ function Public.add_player_to_permission_group(player, group, forced)
not_trusted.set_allows_action(defines.input_action.set_trains_limit, false) not_trusted.set_allows_action(defines.input_action.set_trains_limit, false)
not_trusted.set_allows_action(defines.input_action.set_train_stopped, false) not_trusted.set_allows_action(defines.input_action.set_train_stopped, false)
not_trusted.set_allows_action(defines.input_action.deconstruct, false) not_trusted.set_allows_action(defines.input_action.deconstruct, false)
not_trusted.set_allows_action(defines.input_action.activate_cut, false)
end end
if not AG.enabled then if not AG.enabled then

View File

@ -48,19 +48,15 @@ local function chest_is_valid(chest, inventory)
if chest.type == 'cargo-wagon' then if chest.type == 'cargo-wagon' then
local t = {} local t = {}
local chest_inventory = chest.get_inventory(defines.inventory.cargo_wagon) local chest_inventory = chest.get_inventory(defines.inventory.cargo_wagon)
for i = 1, #inventory do inventory = inventory.get_contents()
local item = inventory[i]
if item.valid_for_read then
for index = 1, 40 do for index = 1, 40 do
if chest_inventory.get_filter(index) ~= nil then if chest_inventory.get_filter(index) ~= nil then
local n = chest_inventory.get_filter(index) local n = chest_inventory.get_filter(index)
if item.name == n then if inventory[n] then
if (t[n] and t[n].valid) then if (t[n] and t[n].valid) then
t[n].count = item.count t[n].count = inventory[n]
else else
t[n] = {count = item.count, valid = true} t[n] = {count = inventory[n], valid = true}
end
end
end end
end end
end end
@ -207,7 +203,7 @@ local function does_inventory_contain_item_type(inventory, item_subgroup)
return false return false
end end
local function insert_item_into_chest(player_inventory, chests, filtered_chests, name, count, durability, furnace, wagon) local function insert_item_into_chest(player_inventory, chests, filtered_chests, name, count, furnace, wagon)
local container = { local container = {
['container'] = true, ['container'] = true,
['logistic-container'] = true ['logistic-container'] = true
@ -253,7 +249,7 @@ local function insert_item_into_chest(player_inventory, chests, filtered_chests,
local valid_to_insert = (amount % 2 == 0) local valid_to_insert = (amount % 2 == 0)
if valid_to_insert then if valid_to_insert then
if chest_inventory.can_insert({name = name, count = amount}) then if chest_inventory.can_insert({name = name, count = amount}) then
local inserted_count = chest_inventory.insert({name = name, count = amount, durability = durability}) local inserted_count = chest_inventory.insert({name = name, count = amount})
player_inventory.remove({name = name, count = inserted_count}) player_inventory.remove({name = name, count = inserted_count})
create_floaty_text(chest.surface, chest.position, name, inserted_count) create_floaty_text(chest.surface, chest.position, name, inserted_count)
count = count - inserted_count count = count - inserted_count
@ -272,7 +268,7 @@ local function insert_item_into_chest(player_inventory, chests, filtered_chests,
end end
else else
if chest_inventory.can_insert({name = name, count = amount}) then if chest_inventory.can_insert({name = name, count = amount}) then
local inserted_count = chest_inventory.insert({name = name, count = amount, durability = durability}) local inserted_count = chest_inventory.insert({name = name, count = amount})
player_inventory.remove({name = name, count = inserted_count}) player_inventory.remove({name = name, count = inserted_count})
create_floaty_text(chest.surface, chest.position, name, inserted_count) create_floaty_text(chest.surface, chest.position, name, inserted_count)
count = count - inserted_count count = count - inserted_count
@ -299,8 +295,8 @@ local function insert_item_into_chest(player_inventory, chests, filtered_chests,
return return
end end
local chest_inventory = chest.get_inventory(defines.inventory.chest) local chest_inventory = chest.get_inventory(defines.inventory.chest)
if chest_inventory and chest_inventory.can_insert({name = name, count = amount, durability = durability}) then if chest_inventory and chest_inventory.can_insert({name = name, count = amount}) then
local inserted_count = chest_inventory.insert({name = name, count = amount, durability = durability}) local inserted_count = chest_inventory.insert({name = name, count = amount})
player_inventory.remove({name = name, count = inserted_count}) player_inventory.remove({name = name, count = inserted_count})
create_floaty_text(chest.surface, chest.position, name, inserted_count) create_floaty_text(chest.surface, chest.position, name, inserted_count)
count = count - inserted_count count = count - inserted_count
@ -312,14 +308,17 @@ local function insert_item_into_chest(player_inventory, chests, filtered_chests,
end end
end end
local stack = player_inventory.find_item_stack(name)
if stack then
-- Attempt to load filtered cargo wagon -- Attempt to load filtered cargo wagon
if wagon then if wagon then
for _, chest in pairs(chests) do for _, chest in pairs(chests) do
if chest.type == 'cargo-wagon' then if chest.type == 'cargo-wagon' then
local chest_inventory = chest.get_inventory(defines.inventory.cargo_wagon) local chest_inventory = chest.get_inventory(defines.inventory.cargo_wagon)
if chest_inventory and chest_inventory.can_insert({name = name, count = count, durability = durability}) then if chest_inventory and chest_inventory.can_insert(stack) then
local inserted_count = chest_inventory.insert({name = name, count = count, durability = durability}) local inserted_count = chest_inventory.insert(stack)
player_inventory.remove({name = name, count = inserted_count}) player_inventory.remove(stack)
create_floaty_text(chest.surface, chest.position, name, inserted_count) create_floaty_text(chest.surface, chest.position, name, inserted_count)
count = count - inserted_count count = count - inserted_count
if count <= 0 then if count <= 0 then
@ -335,11 +334,11 @@ local function insert_item_into_chest(player_inventory, chests, filtered_chests,
if container[chest.type] then if container[chest.type] then
local chest_inventory = chest.get_inventory(defines.inventory.chest) local chest_inventory = chest.get_inventory(defines.inventory.chest)
if chest_inventory and chest_inventory.can_insert({name = name, count = count, durability = durability}) then if chest_inventory and chest_inventory.can_insert(stack) then
if chest_inventory.find_item_stack(name) then if chest_inventory.find_item_stack(name) then
local inserted_count = chest_inventory.insert({name = name, count = count, durability = durability}) local inserted_count = chest_inventory.insert(stack)
player_inventory.remove({name = name, count = inserted_count}) player_inventory.remove(stack)
create_floaty_text(chest.surface, chest.position, name, inserted_count) create_floaty_text(chest.surface, chest.position, name, inserted_count)
count = count - inserted_count count = count - inserted_count
if count <= 0 then if count <= 0 then
@ -354,10 +353,10 @@ local function insert_item_into_chest(player_inventory, chests, filtered_chests,
for _, chest in pairs(filtered_chests) do for _, chest in pairs(filtered_chests) do
if container[chest.type] then if container[chest.type] then
local chest_inventory = chest.get_inventory(defines.inventory.chest) local chest_inventory = chest.get_inventory(defines.inventory.chest)
if chest_inventory and chest_inventory.can_insert({name = name, count = count, durability = durability}) then if chest_inventory and chest_inventory.can_insert(stack) then
if chest_inventory.is_empty() then if chest_inventory.is_empty() then
local inserted_count = chest_inventory.insert({name = name, count = count, durability = durability}) local inserted_count = chest_inventory.insert(stack)
player_inventory.remove({name = name, count = inserted_count}) player_inventory.remove(stack)
create_floaty_text(chest.surface, chest.position, name, inserted_count) create_floaty_text(chest.surface, chest.position, name, inserted_count)
count = count - inserted_count count = count - inserted_count
if count <= 0 then if count <= 0 then
@ -374,10 +373,10 @@ local function insert_item_into_chest(player_inventory, chests, filtered_chests,
for _, chest in pairs(filtered_chests) do for _, chest in pairs(filtered_chests) do
if container[chest.type] then if container[chest.type] then
local chest_inventory = chest.get_inventory(defines.inventory.chest) local chest_inventory = chest.get_inventory(defines.inventory.chest)
if chest_inventory and chest_inventory.can_insert({name = name, count = count, durability = durability}) then if chest_inventory and chest_inventory.can_insert(stack) then
if does_inventory_contain_item_type(chest_inventory, item_subgroup) then if does_inventory_contain_item_type(chest_inventory, item_subgroup) then
local inserted_count = chest_inventory.insert({name = name, count = count, durability = durability}) local inserted_count = chest_inventory.insert(stack)
player_inventory.remove({name = name, count = inserted_count}) player_inventory.remove(stack)
create_floaty_text(chest.surface, chest.position, name, inserted_count) create_floaty_text(chest.surface, chest.position, name, inserted_count)
count = count - inserted_count count = count - inserted_count
if count <= 0 then if count <= 0 then
@ -393,9 +392,9 @@ local function insert_item_into_chest(player_inventory, chests, filtered_chests,
for _, chest in pairs(filtered_chests) do for _, chest in pairs(filtered_chests) do
if container[chest.type] then if container[chest.type] then
local chest_inventory = chest.get_inventory(defines.inventory.chest) local chest_inventory = chest.get_inventory(defines.inventory.chest)
if chest_inventory.can_insert({name = name, count = count, durability = durability}) then if chest_inventory.can_insert(stack) then
local inserted_count = chest_inventory.insert({name = name, count = count, durability = durability}) local inserted_count = chest_inventory.insert(stack)
player_inventory.remove({name = name, count = inserted_count}) player_inventory.remove(stack)
create_floaty_text(chest.surface, chest.position, name, inserted_count) create_floaty_text(chest.surface, chest.position, name, inserted_count)
count = count - inserted_count count = count - inserted_count
if count <= 0 then if count <= 0 then
@ -404,6 +403,7 @@ local function insert_item_into_chest(player_inventory, chests, filtered_chests,
end end
end end
end end
end
end end
local priority = { local priority = {
@ -415,14 +415,11 @@ local priority = {
local function switch_key_val(tbl) local function switch_key_val(tbl)
local t = {} local t = {}
for i = 1, #tbl do for name, count in pairs(tbl) do
local item = tbl[i] if priority[name] then
if item.valid_for_read then t[#t + 1] = {name = name, count = count, priority = priority[name]}
if priority[item.name] then
t[#t + 1] = {name = item.name, count = item.count, durability = item.durability, priority = priority[item.name]}
else else
t[#t + 1] = {name = item.name, count = item.count, durability = item.durability} t[#t + 1] = {name = name, count = count}
end
end end
end end
@ -495,39 +492,38 @@ local function auto_stash(player, event)
end end
end end
local getIndexInventory = switch_key_val(inventory) local getIndexInventory = switch_key_val(inventory.get_contents())
for i = #getIndexInventory, 1, -1 do for i = #getIndexInventory, 1, -1 do
local name = getIndexInventory[i].name local name = getIndexInventory[i].name
local count = getIndexInventory[i].count local count = getIndexInventory[i].count
local durability = getIndexInventory[i].durability
local is_resource = this.whitelist[name] local is_resource = this.whitelist[name]
if not inventory.find_item_stack(name).grid and not hotbar_items[name] then if not inventory.find_item_stack(name).grid and not hotbar_items[name] then
if ctrl and this.insert_into_furnace then if ctrl and this.insert_into_furnace then
if button == defines.mouse_button_type.right then if button == defines.mouse_button_type.right then
if is_resource then if is_resource then
insert_item_into_chest(inventory, chests, filtered_chests, name, count, durability, true, false) insert_item_into_chest(inventory, chests, filtered_chests, name, count, true, false)
end end
end end
elseif shift and this.insert_into_wagon then elseif shift and this.insert_into_wagon then
if button == defines.mouse_button_type.right then if button == defines.mouse_button_type.right then
if is_resource then if is_resource then
insert_item_into_chest(inventory, chests, filtered_chests, name, count, durability, false, true) insert_item_into_chest(inventory, chests, filtered_chests, name, count, false, true)
end end
end end
if button == defines.mouse_button_type.left then if button == defines.mouse_button_type.left then
if filtered_allowed and filtered_allowed[name] and filtered_allowed[name].valid then if filtered_allowed and filtered_allowed[name] and filtered_allowed[name].valid then
local c = filtered_allowed[name].count local c = filtered_allowed[name].count
insert_item_into_chest(inventory, chests, filtered_chests, name, c, durability, false, true) insert_item_into_chest(inventory, chests, filtered_chests, name, c, false, true)
end end
end end
elseif button == defines.mouse_button_type.right then elseif button == defines.mouse_button_type.right then
if is_resource then if is_resource then
insert_item_into_chest(inventory, chests, filtered_chests, name, count, durability) insert_item_into_chest(inventory, chests, filtered_chests, name, count)
end end
elseif button == defines.mouse_button_type.left then elseif button == defines.mouse_button_type.left then
insert_item_into_chest(inventory, chests, filtered_chests, name, count, durability) insert_item_into_chest(inventory, chests, filtered_chests, name, count)
end end
end end
end end

View File

@ -460,7 +460,7 @@ local jail = function(player, griefer, msg, raised)
end end
Utils.print_to(nil, message) Utils.print_to(nil, message)
Utils.action_warning_embed('{Jailed}', message) Utils.action_warning_embed('[Jailed]', message)
if votejail[griefer] then if votejail[griefer] then
votejail[griefer].jailed = true votejail[griefer].jailed = true
@ -489,7 +489,7 @@ local free = function(player, griefer)
set_data(jailed_data_set, griefer, nil) set_data(jailed_data_set, griefer, nil)
Utils.print_to(nil, message) Utils.print_to(nil, message)
Utils.action_warning_embed('{Jailed}', message) Utils.action_warning_embed('[Jailed]', message)
return true return true
end end