mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-24 03:47:58 +02:00
Merge branch 'develop' into develop
This commit is contained in:
commit
8da00da125
@ -212,7 +212,7 @@ local function on_player_ammo_inventory_changed(event)
|
||||
if this.enable_capsule_cursor_warning then
|
||||
local nukes = player.remove_item({name = 'atomic-bomb', count = 1000})
|
||||
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)
|
||||
end
|
||||
end
|
||||
@ -342,7 +342,7 @@ local function on_player_used_capsule(event)
|
||||
return
|
||||
end
|
||||
|
||||
local prefix = '{Capsule}'
|
||||
local prefix = '[Capsule]'
|
||||
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)
|
||||
|
||||
@ -553,7 +553,7 @@ local function on_gui_opened(event)
|
||||
end
|
||||
|
||||
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
|
||||
this.corpse_history = {}
|
||||
end
|
||||
@ -608,7 +608,7 @@ local function on_pre_player_mined_item(event)
|
||||
return
|
||||
end
|
||||
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
|
||||
this.corpse_history = {}
|
||||
end
|
||||
@ -688,7 +688,7 @@ local function on_player_cursor_stack_changed(event)
|
||||
if ammo_names[name] then
|
||||
local item_to_remove = player.remove_item({name = name, count = 1000})
|
||||
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)
|
||||
end
|
||||
end
|
||||
@ -716,7 +716,7 @@ local function on_player_cancelled_crafting(event)
|
||||
player.character.die('player')
|
||||
|
||||
Utils.action_warning(
|
||||
'{Crafting}',
|
||||
'[Crafting]',
|
||||
player.name ..
|
||||
' 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.'
|
||||
@ -778,7 +778,7 @@ local function on_permission_group_added(event)
|
||||
local group = event.group
|
||||
|
||||
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
|
||||
|
||||
@ -794,7 +794,7 @@ local function on_permission_group_deleted(event)
|
||||
local name = event.group_name
|
||||
local id = event.id
|
||||
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
|
||||
|
||||
@ -815,18 +815,18 @@ local function on_permission_group_edited(event)
|
||||
action = k
|
||||
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
|
||||
if event.other_player_index then
|
||||
local other_player = game.get_player(event.other_player_index)
|
||||
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
|
||||
local old_name = event.old_name
|
||||
local new_name = event.new_name
|
||||
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
|
||||
|
||||
@ -839,7 +839,7 @@ local function on_permission_string_imported(event)
|
||||
return
|
||||
end
|
||||
|
||||
Utils.log_msg('{Permission_Group}', player.name .. ' imported a permission string')
|
||||
Utils.log_msg('[Permission_Group]', player.name .. ' imported a permission string')
|
||||
end
|
||||
|
||||
--- This is used for the RPG module, when casting capsules.
|
||||
|
@ -176,20 +176,20 @@ local functions = {
|
||||
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.import_blueprint_string, true)
|
||||
get_actor(event, '{Blueprints}', 'has enabled blueprints!')
|
||||
get_actor(event, '[Blueprints]', 'has enabled blueprints!')
|
||||
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.import_blueprint_string, false)
|
||||
get_actor(event, '{Blueprints}', 'has disabled blueprints!')
|
||||
get_actor(event, '[Blueprints]', 'has disabled blueprints!')
|
||||
end
|
||||
end,
|
||||
['comfy_panel_spaghett_toggle'] = function(event)
|
||||
if event.element.switch_state == 'left' then
|
||||
this.gui_config.spaghett.enabled = true
|
||||
get_actor(event, '{Spaghett}', 'has enabled spaghett mode!')
|
||||
get_actor(event, '[Spaghett]', 'has enabled spaghett mode!')
|
||||
else
|
||||
this.gui_config.spaghett.enabled = nil
|
||||
get_actor(event, '{Spaghett}', 'has disabled spaghett mode!')
|
||||
get_actor(event, '[Spaghett]', 'has disabled spaghett mode!')
|
||||
end
|
||||
spaghett()
|
||||
end,
|
||||
@ -225,10 +225,10 @@ local poll_function = {
|
||||
['comfy_panel_poll_trusted_toggle'] = function(event)
|
||||
if event.element.switch_state == 'left' then
|
||||
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
|
||||
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,
|
||||
['comfy_panel_poll_no_notify_toggle'] = function(event)
|
||||
@ -247,10 +247,10 @@ local antigrief_functions = {
|
||||
local AG = Antigrief.get()
|
||||
if event.element.switch_state == 'left' then
|
||||
AG.enabled = true
|
||||
get_actor(event, '{Antigrief}', 'has enabled the antigrief function.', true)
|
||||
get_actor(event, '[Antigrief]', 'has enabled the antigrief function.', true)
|
||||
else
|
||||
AG.enabled = false
|
||||
get_actor(event, '{Antigrief}', 'has disabled the antigrief function.', true)
|
||||
get_actor(event, '[Antigrief]', 'has disabled the antigrief function.', true)
|
||||
end
|
||||
trust_connected_players()
|
||||
end
|
||||
@ -262,10 +262,10 @@ local fortress_functions = {
|
||||
local Module = Fullness.get()
|
||||
if event.element.switch_state == 'left' then
|
||||
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
|
||||
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,
|
||||
['comfy_panel_offline_players'] = function(event)
|
||||
@ -273,10 +273,10 @@ local fortress_functions = {
|
||||
local Module = WPT.get()
|
||||
if event.element.switch_state == 'left' then
|
||||
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
|
||||
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,
|
||||
['comfy_panel_collapse_grace'] = function(event)
|
||||
@ -284,10 +284,10 @@ local fortress_functions = {
|
||||
local Module = WPT.get()
|
||||
if event.element.switch_state == 'left' then
|
||||
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
|
||||
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,
|
||||
['comfy_panel_spill_items_to_surface'] = function(event)
|
||||
@ -295,10 +295,10 @@ local fortress_functions = {
|
||||
local Module = WPT.get()
|
||||
if event.element.switch_state == 'left' then
|
||||
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
|
||||
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,
|
||||
['comfy_panel_void_or_tile'] = function(event)
|
||||
@ -306,10 +306,10 @@ local fortress_functions = {
|
||||
local Module = WPT.get()
|
||||
if event.element.switch_state == 'left' then
|
||||
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
|
||||
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,
|
||||
['comfy_panel_trusted_only_car_tanks'] = function(event)
|
||||
@ -317,10 +317,10 @@ local fortress_functions = {
|
||||
local Module = WPT.get()
|
||||
if event.element.switch_state == 'left' then
|
||||
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
|
||||
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
|
||||
}
|
||||
|
@ -660,7 +660,7 @@ function Public.save_car(ic, event)
|
||||
|
||||
log_err(ic, 'Owner of this vehicle is: ' .. p.name)
|
||||
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)
|
||||
local params = {
|
||||
player = player,
|
||||
@ -745,7 +745,7 @@ function Public.validate_owner(ic, player, entity)
|
||||
if car.owner ~= player.index and player.driving then
|
||||
player.driving = false
|
||||
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
|
||||
|
@ -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.drop_item, 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')
|
||||
default_group.set_allows_action(defines.input_action.deconstruct, false)
|
||||
default_group.set_allows_action(defines.input_action.activate_cut, false)
|
||||
end
|
||||
|
||||
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.admin_action, false)
|
||||
plebs_group.set_allows_action(defines.input_action.deconstruct, false)
|
||||
plebs_group.set_allows_action(defines.input_action.activate_cut, false)
|
||||
end
|
||||
|
||||
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_train_stopped, false)
|
||||
not_trusted.set_allows_action(defines.input_action.deconstruct, false)
|
||||
not_trusted.set_allows_action(defines.input_action.activate_cut, false)
|
||||
end
|
||||
|
||||
if not AG.enabled then
|
||||
|
@ -48,19 +48,15 @@ local function chest_is_valid(chest, inventory)
|
||||
if chest.type == 'cargo-wagon' then
|
||||
local t = {}
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.cargo_wagon)
|
||||
for i = 1, #inventory do
|
||||
local item = inventory[i]
|
||||
if item.valid_for_read then
|
||||
for index = 1, 40 do
|
||||
if chest_inventory.get_filter(index) ~= nil then
|
||||
local n = chest_inventory.get_filter(index)
|
||||
if item.name == n then
|
||||
if (t[n] and t[n].valid) then
|
||||
t[n].count = item.count
|
||||
else
|
||||
t[n] = {count = item.count, valid = true}
|
||||
end
|
||||
end
|
||||
inventory = inventory.get_contents()
|
||||
for index = 1, 40 do
|
||||
if chest_inventory.get_filter(index) ~= nil then
|
||||
local n = chest_inventory.get_filter(index)
|
||||
if inventory[n] then
|
||||
if (t[n] and t[n].valid) then
|
||||
t[n].count = inventory[n]
|
||||
else
|
||||
t[n] = {count = inventory[n], valid = true}
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -207,7 +203,7 @@ local function does_inventory_contain_item_type(inventory, item_subgroup)
|
||||
return false
|
||||
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 = {
|
||||
['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)
|
||||
if valid_to_insert 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})
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
count = count - inserted_count
|
||||
@ -272,7 +268,7 @@ local function insert_item_into_chest(player_inventory, chests, filtered_chests,
|
||||
end
|
||||
else
|
||||
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})
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
count = count - inserted_count
|
||||
@ -299,8 +295,8 @@ local function insert_item_into_chest(player_inventory, chests, filtered_chests,
|
||||
return
|
||||
end
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.chest)
|
||||
if chest_inventory and chest_inventory.can_insert({name = name, count = amount, durability = durability}) then
|
||||
local inserted_count = chest_inventory.insert({name = name, count = amount, durability = durability})
|
||||
if chest_inventory and chest_inventory.can_insert({name = name, count = amount}) then
|
||||
local inserted_count = chest_inventory.insert({name = name, count = amount})
|
||||
player_inventory.remove({name = name, count = inserted_count})
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
count = count - inserted_count
|
||||
@ -312,72 +308,17 @@ local function insert_item_into_chest(player_inventory, chests, filtered_chests,
|
||||
end
|
||||
end
|
||||
|
||||
-- Attempt to load filtered cargo wagon
|
||||
if wagon then
|
||||
for _, chest in pairs(chests) do
|
||||
if chest.type == 'cargo-wagon' then
|
||||
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
|
||||
local inserted_count = chest_inventory.insert({name = name, count = count, durability = durability})
|
||||
player_inventory.remove({name = name, count = inserted_count})
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
count = count - inserted_count
|
||||
if count <= 0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local stack = player_inventory.find_item_stack(name)
|
||||
|
||||
--Attempt to store in chests that already have the same item.
|
||||
for _, chest in pairs(chests) do
|
||||
if container[chest.type] then
|
||||
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.find_item_stack(name) then
|
||||
local inserted_count = chest_inventory.insert({name = name, count = count, durability = durability})
|
||||
|
||||
player_inventory.remove({name = name, count = inserted_count})
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
count = count - inserted_count
|
||||
if count <= 0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--Attempt to store in empty chests.
|
||||
for _, chest in pairs(filtered_chests) do
|
||||
if container[chest.type] then
|
||||
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.is_empty() then
|
||||
local inserted_count = chest_inventory.insert({name = name, count = count, durability = durability})
|
||||
player_inventory.remove({name = name, count = inserted_count})
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
count = count - inserted_count
|
||||
if count <= 0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--Attempt to store in chests with same item subgroup.
|
||||
local item_subgroup = game.item_prototypes[name].subgroup.name
|
||||
if item_subgroup then
|
||||
for _, chest in pairs(filtered_chests) do
|
||||
if container[chest.type] then
|
||||
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 does_inventory_contain_item_type(chest_inventory, item_subgroup) then
|
||||
local inserted_count = chest_inventory.insert({name = name, count = count, durability = durability})
|
||||
player_inventory.remove({name = name, count = inserted_count})
|
||||
if stack then
|
||||
-- Attempt to load filtered cargo wagon
|
||||
if wagon then
|
||||
for _, chest in pairs(chests) do
|
||||
if chest.type == 'cargo-wagon' then
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.cargo_wagon)
|
||||
if chest_inventory and chest_inventory.can_insert(stack) then
|
||||
local inserted_count = chest_inventory.insert(stack)
|
||||
player_inventory.remove(stack)
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
count = count - inserted_count
|
||||
if count <= 0 then
|
||||
@ -387,19 +328,78 @@ local function insert_item_into_chest(player_inventory, chests, filtered_chests,
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--Attempt to store in mixed chests.
|
||||
for _, chest in pairs(filtered_chests) do
|
||||
if container[chest.type] then
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.chest)
|
||||
if chest_inventory.can_insert({name = name, count = count, durability = durability}) then
|
||||
local inserted_count = chest_inventory.insert({name = name, count = count, durability = durability})
|
||||
player_inventory.remove({name = name, count = inserted_count})
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
count = count - inserted_count
|
||||
if count <= 0 then
|
||||
return
|
||||
--Attempt to store in chests that already have the same item.
|
||||
for _, chest in pairs(chests) do
|
||||
if container[chest.type] then
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.chest)
|
||||
|
||||
if chest_inventory and chest_inventory.can_insert(stack) then
|
||||
if chest_inventory.find_item_stack(name) then
|
||||
local inserted_count = chest_inventory.insert(stack)
|
||||
|
||||
player_inventory.remove(stack)
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
count = count - inserted_count
|
||||
if count <= 0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--Attempt to store in empty chests.
|
||||
for _, chest in pairs(filtered_chests) do
|
||||
if container[chest.type] then
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.chest)
|
||||
if chest_inventory and chest_inventory.can_insert(stack) then
|
||||
if chest_inventory.is_empty() then
|
||||
local inserted_count = chest_inventory.insert(stack)
|
||||
player_inventory.remove(stack)
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
count = count - inserted_count
|
||||
if count <= 0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--Attempt to store in chests with same item subgroup.
|
||||
local item_subgroup = game.item_prototypes[name].subgroup.name
|
||||
if item_subgroup then
|
||||
for _, chest in pairs(filtered_chests) do
|
||||
if container[chest.type] then
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.chest)
|
||||
if chest_inventory and chest_inventory.can_insert(stack) then
|
||||
if does_inventory_contain_item_type(chest_inventory, item_subgroup) then
|
||||
local inserted_count = chest_inventory.insert(stack)
|
||||
player_inventory.remove(stack)
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
count = count - inserted_count
|
||||
if count <= 0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--Attempt to store in mixed chests.
|
||||
for _, chest in pairs(filtered_chests) do
|
||||
if container[chest.type] then
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.chest)
|
||||
if chest_inventory.can_insert(stack) then
|
||||
local inserted_count = chest_inventory.insert(stack)
|
||||
player_inventory.remove(stack)
|
||||
create_floaty_text(chest.surface, chest.position, name, inserted_count)
|
||||
count = count - inserted_count
|
||||
if count <= 0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -415,14 +415,11 @@ local priority = {
|
||||
|
||||
local function switch_key_val(tbl)
|
||||
local t = {}
|
||||
for i = 1, #tbl do
|
||||
local item = tbl[i]
|
||||
if item.valid_for_read then
|
||||
if priority[item.name] then
|
||||
t[#t + 1] = {name = item.name, count = item.count, durability = item.durability, priority = priority[item.name]}
|
||||
else
|
||||
t[#t + 1] = {name = item.name, count = item.count, durability = item.durability}
|
||||
end
|
||||
for name, count in pairs(tbl) do
|
||||
if priority[name] then
|
||||
t[#t + 1] = {name = name, count = count, priority = priority[name]}
|
||||
else
|
||||
t[#t + 1] = {name = name, count = count}
|
||||
end
|
||||
end
|
||||
|
||||
@ -495,39 +492,38 @@ local function auto_stash(player, event)
|
||||
end
|
||||
end
|
||||
|
||||
local getIndexInventory = switch_key_val(inventory)
|
||||
local getIndexInventory = switch_key_val(inventory.get_contents())
|
||||
|
||||
for i = #getIndexInventory, 1, -1 do
|
||||
local name = getIndexInventory[i].name
|
||||
local count = getIndexInventory[i].count
|
||||
local durability = getIndexInventory[i].durability
|
||||
local is_resource = this.whitelist[name]
|
||||
|
||||
if not inventory.find_item_stack(name).grid and not hotbar_items[name] then
|
||||
if ctrl and this.insert_into_furnace then
|
||||
if button == defines.mouse_button_type.right 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
|
||||
elseif shift and this.insert_into_wagon then
|
||||
if button == defines.mouse_button_type.right 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
|
||||
if button == defines.mouse_button_type.left then
|
||||
if filtered_allowed and filtered_allowed[name] and filtered_allowed[name].valid then
|
||||
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
|
||||
elseif button == defines.mouse_button_type.right 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
|
||||
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
|
||||
|
@ -460,7 +460,7 @@ local jail = function(player, griefer, msg, raised)
|
||||
end
|
||||
|
||||
Utils.print_to(nil, message)
|
||||
Utils.action_warning_embed('{Jailed}', message)
|
||||
Utils.action_warning_embed('[Jailed]', message)
|
||||
|
||||
if votejail[griefer] then
|
||||
votejail[griefer].jailed = true
|
||||
@ -489,7 +489,7 @@ local free = function(player, griefer)
|
||||
set_data(jailed_data_set, griefer, nil)
|
||||
|
||||
Utils.print_to(nil, message)
|
||||
Utils.action_warning_embed('{Jailed}', message)
|
||||
Utils.action_warning_embed('[Jailed]', message)
|
||||
return true
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user