mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-03 13:12:11 +02:00
Fix minor issues
This commit is contained in:
parent
2a6224a6bc
commit
de6fb86efb
@ -1193,12 +1193,20 @@ function Public.set_difficulty()
|
||||
elseif player_count >= 11 then
|
||||
mining_bonus = 0 -- back to 0% with more than 11 players
|
||||
end
|
||||
if mining_bonus < 0 then
|
||||
mining_bonus = 0
|
||||
end
|
||||
|
||||
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + mining_bonus
|
||||
Public.set('mining_bonus', mining_bonus) -- Setting mining_bonus globally so it remembers how much to reduce
|
||||
else
|
||||
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier - mining_bonus
|
||||
Public.set('disable_mining_boost', true)
|
||||
end
|
||||
|
||||
if force.manual_mining_speed_modifier < 0 then
|
||||
force.manual_mining_speed_modifier = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -372,6 +372,9 @@ end
|
||||
local function get_all_chests(unit_number)
|
||||
local t = {}
|
||||
local loco_surface = WPT.get('loco_surface')
|
||||
if not loco_surface then
|
||||
return t
|
||||
end
|
||||
local containers = this.main_containers
|
||||
for check_unit_number, container in pairs(containers) do
|
||||
if container.chest and container.chest.valid and container.share.name ~= '' and container.share.name ~= container.unit_number and container.chest.surface.index == loco_surface.index then
|
||||
@ -842,13 +845,13 @@ local function update_gui()
|
||||
|
||||
local content = container.chest.get_inventory(defines.inventory.chest).get_contents()
|
||||
|
||||
for item_name, item_count in pairs(content) do
|
||||
if item_name ~= 'count' then
|
||||
if not items[item_name] then
|
||||
for _, data in pairs(content) do
|
||||
if data.name ~= 'count' then
|
||||
if not items[data.name] then
|
||||
total = total + 1
|
||||
items[item_name] = item_count
|
||||
items[data.name] = data.count
|
||||
else
|
||||
items[item_name] = items[item_name] + item_count
|
||||
items[data.name] = items[data.name] + data.count
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -999,9 +1002,9 @@ local function content_mismatches(source, destination)
|
||||
|
||||
local mismatch = false
|
||||
|
||||
for source_item_name, _ in pairs(source_inventory) do
|
||||
for destination_item_name, _ in pairs(destination_inventory) do
|
||||
if source_item_name ~= destination_item_name then
|
||||
for _, source_items in pairs(source_inventory) do
|
||||
for _, destination_items in pairs(destination_inventory) do
|
||||
if source_items.name ~= destination_items.name then
|
||||
mismatch = true
|
||||
end
|
||||
end
|
||||
|
@ -5,6 +5,7 @@ local Public = {}
|
||||
|
||||
Public.reset = ICW.reset
|
||||
Public.get_table = ICW.get
|
||||
Public.get = ICW.get
|
||||
|
||||
local function on_entity_died(event)
|
||||
local entity = event.entity
|
||||
|
@ -307,8 +307,8 @@ local function give_passive_xp(data)
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif player.afk_time > 1800 and player.character and player.surface.index == loco_surface.index then
|
||||
player.character_personal_logistic_requests_enabled = false
|
||||
elseif player.afk_time > 1800 and player.character and player.surface.index == loco_surface.index and player.get_requester_point() then
|
||||
player.get_requester_point().enabled = false
|
||||
end
|
||||
::pre_exit::
|
||||
end
|
||||
@ -408,7 +408,12 @@ local function get_driver_action(entity)
|
||||
return
|
||||
end
|
||||
|
||||
local player = driver.player
|
||||
local player
|
||||
if driver and driver.valid and driver.is_player() then
|
||||
player = driver
|
||||
else
|
||||
player = driver.player
|
||||
end
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
@ -493,7 +498,8 @@ local function validate_index()
|
||||
|
||||
local icw_table = ICW.get_table()
|
||||
local icw_locomotive = Public.get('icw_locomotive')
|
||||
if not icw_locomotive or not icw_locomotive.valid then
|
||||
if not icw_locomotive then
|
||||
Event.raise(Public.events.on_locomotive_cargo_missing)
|
||||
return
|
||||
end
|
||||
local loco_surface = icw_locomotive.surface
|
||||
|
@ -1526,6 +1526,10 @@ local function gui_closed(event)
|
||||
end
|
||||
|
||||
local function on_gui_selection_state_changed(event)
|
||||
if not event.element or not event.element.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local name = event.element.name
|
||||
local player = game.get_player(event.player_index)
|
||||
local selected_index = event.element.selected_index
|
||||
|
@ -2,7 +2,7 @@ local Public = require 'maps.mountain_fortress_v3.table'
|
||||
local ICW = require 'maps.mountain_fortress_v3.icw.main'
|
||||
local Task = require 'utils.task_token'
|
||||
local MapFunctions = require 'utils.tools.map_functions'
|
||||
|
||||
local Event = require 'utils.event'
|
||||
local random = math.random
|
||||
local floor = math.floor
|
||||
|
||||
@ -205,7 +205,7 @@ function Public.locomotive_spawn(surface, position, reversed)
|
||||
)
|
||||
end
|
||||
|
||||
local s = 'entity/character-corpse'
|
||||
local s = 'entity/fish'
|
||||
|
||||
for y = -1, 0, 0.05 do
|
||||
local scale = random(50, 100) * 0.01
|
||||
@ -230,6 +230,7 @@ function Public.locomotive_spawn(surface, position, reversed)
|
||||
|
||||
local locomotive = ICW.register_wagon(this.locomotive)
|
||||
if not locomotive then
|
||||
print('Failed to register locomotive')
|
||||
return
|
||||
end
|
||||
|
||||
@ -274,4 +275,17 @@ function Public.locomotive_spawn(surface, position, reversed)
|
||||
game.forces.player.set_spawn_position({ this.locomotive.position.x - 5, this.locomotive.position.y }, locomotive.surface)
|
||||
end
|
||||
|
||||
Event.add(Public.events.on_locomotive_cargo_missing, function ()
|
||||
local locomotive_cargo = Public.get('locomotive_cargo')
|
||||
if not locomotive_cargo or not locomotive_cargo.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local wagons = ICW.get('wagons')
|
||||
if wagons[locomotive_cargo.unit_number] then
|
||||
log('Locomotive cargo missing, setting new cargo')
|
||||
Public.set('icw_locomotive', wagons[locomotive_cargo.unit_number])
|
||||
end
|
||||
end)
|
||||
|
||||
return Public
|
||||
|
@ -38,7 +38,8 @@ local dataset_key_dev = 'mtn_v3_table_dev'
|
||||
Public.events = {
|
||||
reset_map = Event.generate_event_name('reset_map'),
|
||||
on_entity_mined = Event.generate_event_name('on_entity_mined'),
|
||||
on_market_item_purchased = Event.generate_event_name('on_market_item_purchased')
|
||||
on_market_item_purchased = Event.generate_event_name('on_market_item_purchased'),
|
||||
on_locomotive_cargo_missing = Event.generate_event_name('on_locomotive_cargo_missing'),
|
||||
}
|
||||
|
||||
local scenario_name = 'nauvis'
|
||||
|
@ -351,7 +351,7 @@ local function place_wagon(data, adjusted_zones)
|
||||
direction = 0
|
||||
else
|
||||
location = surface.find_tiles_filtered({ area = { { position.x - r1, position.y }, { position.x + r2, position.y + 2 } } })
|
||||
direction = 2
|
||||
direction = 4
|
||||
end
|
||||
|
||||
for _, tile in pairs(location) do
|
||||
|
@ -27,13 +27,13 @@ local function compute_fullness(player)
|
||||
local num_stacks = 0
|
||||
|
||||
local contents = inv.get_contents()
|
||||
for item, count in pairs(contents) do
|
||||
for _, items in pairs(contents) do
|
||||
local stack_size = 1
|
||||
if prototypes.item[item].stackable then
|
||||
stack_size = prototypes.item[item].stack_size
|
||||
if prototypes.item[items.name].stackable then
|
||||
stack_size = prototypes.item[items.name].stack_size
|
||||
end
|
||||
|
||||
num_stacks = num_stacks + count / stack_size
|
||||
num_stacks = num_stacks + items.count / stack_size
|
||||
end
|
||||
|
||||
return num_stacks / max_stacks
|
||||
|
@ -41,7 +41,7 @@ local function on_console_chat(event)
|
||||
return
|
||||
end
|
||||
|
||||
if player.character.surface ~= player.surface.index then return end
|
||||
if player.character.surface.index ~= player.surface.index then return end
|
||||
|
||||
this.player_floaty_chat[player.index] =
|
||||
rendering.draw_text {
|
||||
|
@ -164,11 +164,16 @@ local function zoom_to_pos(event)
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
local player = event.player
|
||||
local player = event.player
|
||||
local element = event.element
|
||||
local position = Gui.get_data(element)
|
||||
local target = Gui.get_data(element)
|
||||
|
||||
player.zoom_to_world(position, 0.5)
|
||||
if not target or not target.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if target.character ~= nil then target = target.character end
|
||||
player.centered_on = target
|
||||
end
|
||||
|
||||
local close_alert = Public.close_alert
|
||||
@ -285,7 +290,7 @@ function Public.alert_all_players_location(player, message, color, duration)
|
||||
style = 'slot_button'
|
||||
}
|
||||
|
||||
Gui.set_data(sprite, player.position)
|
||||
Gui.set_data(sprite, player)
|
||||
|
||||
local label =
|
||||
container.add {
|
||||
|
@ -577,6 +577,7 @@ Public.new('get', 'Hover over an object to get its name.')
|
||||
player.print('[color=orange]Name:[/color] ' .. entity.name)
|
||||
player.print('[color=orange]Type:[/color] ' .. entity.type)
|
||||
player.print('[color=orange]Force:[/color] ' .. entity.force.name)
|
||||
player.print('[color=orange]Direction:[/color] ' .. entity.direction)
|
||||
player.print('[color=orange]Destructible:[/color] ' .. (entity.destructible and 'true' or 'false'))
|
||||
player.print('[color=orange]Minable:[/color] ' .. (entity.minable and 'true' or 'false'))
|
||||
player.print('[color=orange]Unit Number:[/color] ' .. (entity.unit_number or 'nil'))
|
||||
|
@ -44,7 +44,7 @@ local function remove_player_data(player)
|
||||
local player_data = this.players[player.index]
|
||||
if player_data then
|
||||
if player_data.render_object then
|
||||
rendering.destroy(player_data.render_object)
|
||||
player_data.render_object.destroy()
|
||||
end
|
||||
|
||||
this.players[player.index] = nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user