mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-22 03:38:48 +02:00
Merge pull request #448 from ComfyFactory/module_fixes
Fixes some issues with some modules
This commit is contained in:
commit
c09f550405
@ -8,6 +8,7 @@ local Gui = require 'utils.gui'
|
||||
local Color = require 'utils.color_presets'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
local Polls = require 'utils.gui.poll'
|
||||
local BottomFrame = require 'utils.gui.bottom_frame'
|
||||
|
||||
local format_number = require 'util'.format_number
|
||||
|
||||
@ -215,6 +216,7 @@ local function changed_surface(player)
|
||||
local rpg_s = player.gui.screen[rpg_settings]
|
||||
local diff = player.gui.top[Difficulty.top_button_name]
|
||||
local charging = player.gui.top['charging_station']
|
||||
local charging_frame = BottomFrame.get_section(player, 'charging_station')
|
||||
local frame = player.gui.top[main_frame_name]
|
||||
local spell_gui_frame_name = RPG.spell_gui_frame_name
|
||||
local spell_cast_buttons = player.gui.screen[spell_gui_frame_name]
|
||||
@ -270,6 +272,9 @@ local function changed_surface(player)
|
||||
if charging and not charging.visible then
|
||||
charging.visible = true
|
||||
end
|
||||
if charging_frame and not charging_frame.enabled then
|
||||
charging_frame.enabled = true
|
||||
end
|
||||
if info then
|
||||
info.tooltip = ({'gui.info_tooltip'})
|
||||
info.sprite = 'item/dummy-steel-axe'
|
||||
@ -309,6 +314,9 @@ local function changed_surface(player)
|
||||
if charging then
|
||||
charging.visible = false
|
||||
end
|
||||
if charging_frame and charging_frame.enabled then
|
||||
charging_frame.enabled = false
|
||||
end
|
||||
if info then
|
||||
info.tooltip = ({'gui.hide_minimap'})
|
||||
info.sprite = 'utility/map'
|
||||
@ -449,6 +457,7 @@ local function enable_guis(event)
|
||||
local rpg_b = player.gui.top[rpg_button]
|
||||
local diff = player.gui.top[Difficulty.top_button_name]
|
||||
local charging = player.gui.top['charging_station']
|
||||
local charging_frame = BottomFrame.get_section(player, 'charging_station')
|
||||
|
||||
IC_Gui.remove_toolbar(player)
|
||||
IC_Minimap.toggle_button(player)
|
||||
@ -483,6 +492,9 @@ local function enable_guis(event)
|
||||
if charging and not charging.visible then
|
||||
charging.visible = true
|
||||
end
|
||||
if charging_frame and not charging.enabled then
|
||||
charging.enabled = true
|
||||
end
|
||||
if info then
|
||||
info.tooltip = ({'gui.info_tooltip'})
|
||||
info.sprite = 'item/dummy-steel-axe'
|
||||
|
@ -44,12 +44,12 @@ local on_init_token =
|
||||
local tooltip
|
||||
if this.insert_into_furnace and this.insert_into_wagon then
|
||||
tooltip =
|
||||
'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.\nCTRL+RMB: Fill nearby furnaces.\nSHIFT+LMB: Everything onto filtered slots to wagon.\nSHIFT+RMB: Only ores to wagon'
|
||||
'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.\nCTRL+RMB: Fill nearby furnaces.\nSHIFT+LMB: Everything onto filtered slots to wagon/chests.\nSHIFT+RMB: Only ores to wagon'
|
||||
elseif this.insert_into_furnace then
|
||||
tooltip = 'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.\nCTRL+RMB: Fill nearby furnaces.'
|
||||
elseif this.insert_into_wagon then
|
||||
tooltip =
|
||||
'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.\nSHIFT+LMB: Everything onto filtered slots to wagon.\nSHIFT+RMB: Only ores to wagon'
|
||||
'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.\nSHIFT+LMB: Everything onto filtered slots to wagon/chests.\nSHIFT+RMB: Only ores to wagon'
|
||||
else
|
||||
tooltip = 'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.'
|
||||
end
|
||||
@ -222,7 +222,7 @@ local function get_nearby_chests(player, a, furnace, wagon)
|
||||
inventory_type = defines.inventory.furnace_source
|
||||
end
|
||||
if wagon then
|
||||
container_type = {'cargo-wagon'}
|
||||
container_type = {'cargo-wagon', 'logistic-container'}
|
||||
inventory_type = defines.inventory.cargo_wagon
|
||||
end
|
||||
|
||||
@ -390,6 +390,28 @@ local function insert_into_wagon_filtered(stack, chests, name, floaty_text_list)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Attempt to load filtered slots
|
||||
for chestnr, chest in pairs(chests.chest) do
|
||||
if chest.type == 'logistic-container' then
|
||||
local chest_inventory = chests.inventory[chestnr]
|
||||
for index = 1, chest.request_slot_count do
|
||||
if chest_inventory.can_insert(stack) then
|
||||
if chest.get_request_slot(index) ~= nil then
|
||||
local n = chest.get_request_slot(index)
|
||||
if n and n.name == name then
|
||||
local inserted_count = chest_inventory.insert(stack)
|
||||
stack.count = stack.count - inserted_count
|
||||
prepare_floaty_text(floaty_text_list, chest.surface, chest.position, name, inserted_count)
|
||||
if stack.count <= 0 then
|
||||
return chestnr
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function insert_item_into_chest(stack, chests, filtered_chests, name, floaty_text_list, previous_insert)
|
||||
@ -411,9 +433,34 @@ local function insert_item_into_chest(stack, chests, filtered_chests, name, floa
|
||||
end
|
||||
end
|
||||
|
||||
--- Attempt to store in req slots that are filtered
|
||||
for chestnr, chest in pairs(chests.chest) do
|
||||
if chest.type == 'logistic-container' then
|
||||
local chest_inventory = chests.inventory[chestnr]
|
||||
for index = 1, chest.request_slot_count do
|
||||
if chest_inventory.can_insert(stack) then
|
||||
if chest.get_request_slot(index) ~= nil then
|
||||
local n = chest.get_request_slot(index)
|
||||
if n and n.name == name then
|
||||
local inserted_count = chest_inventory.insert(stack)
|
||||
stack.count = stack.count - inserted_count
|
||||
prepare_floaty_text(floaty_text_list, chest.surface, chest.position, name, inserted_count)
|
||||
if stack.count <= 0 then
|
||||
return chestnr
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--Attempt to store in chests that already have the same item.
|
||||
for chestnr, chest in pairs(chests.chest) do
|
||||
if container[chest.type] then
|
||||
if chest.request_slot_count and chest.request_slot_count > 0 then
|
||||
goto continue
|
||||
end
|
||||
local chest_inventory = chests.inventory[chestnr]
|
||||
if chest_inventory and chest_inventory.find_item_stack(stack.name) then
|
||||
if chest_inventory.can_insert(stack) then
|
||||
@ -425,12 +472,16 @@ local function insert_item_into_chest(stack, chests, filtered_chests, name, floa
|
||||
end
|
||||
end
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
--Attempt to store in empty chests.
|
||||
for chestnr, chest in pairs(filtered_chests.chest) do
|
||||
if container[chest.type] then
|
||||
if chest.request_slot_count and chest.request_slot_count > 0 then
|
||||
goto continue
|
||||
end
|
||||
local chest_inventory = filtered_chests.inventory[chestnr]
|
||||
if not chest_inventory then
|
||||
break
|
||||
@ -444,6 +495,7 @@ local function insert_item_into_chest(stack, chests, filtered_chests, name, floa
|
||||
return chestnr
|
||||
end
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
@ -453,6 +505,9 @@ local function insert_item_into_chest(stack, chests, filtered_chests, name, floa
|
||||
local item_subgroup = game.item_prototypes[name].subgroup.name
|
||||
if item_subgroup then
|
||||
for chestnr, chest in pairs(filtered_chests.chest) do
|
||||
if chest.request_slot_count and chest.request_slot_count > 0 then
|
||||
goto continue
|
||||
end
|
||||
if container[chest.type] then
|
||||
local chest_inventory = filtered_chests.inventory[chestnr]
|
||||
if not chest_inventory then
|
||||
@ -473,12 +528,16 @@ local function insert_item_into_chest(stack, chests, filtered_chests, name, floa
|
||||
end
|
||||
end
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
--Attempt to store in mixed chests.
|
||||
for chestnr, chest in pairs(filtered_chests.chest) do
|
||||
if container[chest.type] then
|
||||
if chest.request_slot_count and chest.request_slot_count > 0 then
|
||||
goto continue
|
||||
end
|
||||
local chest_inventory = filtered_chests.inventory[chestnr]
|
||||
if not chest_inventory then
|
||||
break
|
||||
@ -491,6 +550,7 @@ local function insert_item_into_chest(stack, chests, filtered_chests, name, floa
|
||||
return chestnr
|
||||
end
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1296,6 +1296,8 @@ function Public.rpg_reset_player(player, one_time_reset)
|
||||
end
|
||||
end
|
||||
|
||||
Modifiers.reset_player_modifiers(player)
|
||||
|
||||
Public.draw_gui_char_button(player)
|
||||
Public.draw_level_text(player)
|
||||
Public.update_char_button(player)
|
||||
|
@ -729,7 +729,7 @@ local function on_player_crafted_item(event)
|
||||
if tweaked_crafting_items_enabled then
|
||||
if item and item.valid then
|
||||
if is_blacklisted[item.name] then
|
||||
amount = 0.2
|
||||
return -- return if the item is blacklisted
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -50,32 +50,6 @@ local sections = {
|
||||
[12] = 6
|
||||
}
|
||||
|
||||
--[[ local restore_bottom_location_token =
|
||||
Task.register(
|
||||
function(event)
|
||||
local player_index = event.player_index
|
||||
local player = game.get_player(player_index)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local state = event.state
|
||||
if not state then
|
||||
return
|
||||
end
|
||||
|
||||
local bottom_right = event.bottom_right or 'bottom_right'
|
||||
local above = event.above or false
|
||||
|
||||
local data = get_player_data(player)
|
||||
|
||||
data.bottom_right = bottom_right
|
||||
data.above = above
|
||||
data.state = state
|
||||
|
||||
set_location(player, state)
|
||||
end
|
||||
) ]]
|
||||
local check_bottom_buttons_token =
|
||||
Task.register(
|
||||
function(event)
|
||||
@ -420,6 +394,30 @@ function Public.toggle_player_frame(player, state)
|
||||
end
|
||||
end
|
||||
|
||||
--- Returns the current frame of the given player
|
||||
---@param player LuaPlayer
|
||||
---@param section_name string
|
||||
---@return table|boolean|nil
|
||||
function Public.get_section(player, section_name)
|
||||
local data = get_player_data(player)
|
||||
local section = data.section
|
||||
if not section then
|
||||
return false
|
||||
end
|
||||
|
||||
for _, section_tbl in pairs(section) do
|
||||
if not section_tbl or not next(section_tbl) then
|
||||
break
|
||||
end
|
||||
|
||||
for _, section_data in pairs(section_tbl) do
|
||||
if section_data and section_data.valid and section_data.name == section_name then
|
||||
return section_data
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Retrieves the value associated with the specified key.
|
||||
--- @param key any The key to retrieve the value for.
|
||||
--- @return any The value associated with the key.
|
||||
|
Loading…
x
Reference in New Issue
Block a user