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

pirates: wire connections and other stuff

This commit is contained in:
danielmartin0 2024-09-26 01:08:35 +01:00 committed by Gerkiz
parent 0e2f0401ae
commit a98ef91e9c
16 changed files with 128 additions and 181 deletions

View File

@ -531,7 +531,7 @@ gui_runs_proposal_maker_run_name_2=Name
gui_runs_proposal_maker_capacity=Capacity gui_runs_proposal_maker_capacity=Capacity
gui_runs_proposal_maker_propose=Propose gui_runs_proposal_maker_propose=Propose
gui_runs_proposal_maker_no_limit=No limit gui_runs_proposal_maker_no_limit=No limit
gui_runs_proposal_maker_blueprints_disabled=Blueprint imports disabled gui_runs_proposal_maker_blueprints_disabled=Disable BP Imports
gui_runs_proposal_maker_protected=Captain-protected gui_runs_proposal_maker_protected=Captain-protected
gui_runs_proposal_maker_protected_tooltip=Captain-protected crew. If the captain leaves or becomes afk, and there are no officers, the captain role stays vacant. gui_runs_proposal_maker_protected_tooltip=Captain-protected crew. If the captain leaves or becomes afk, and there are no officers, the captain role stays vacant.
gui_runs_proposal_maker_private=Private gui_runs_proposal_maker_private=Private

View File

@ -171,7 +171,7 @@ function Public.try_main_attack()
local wave_size_multiplier = Public.wave_size_rng() local wave_size_multiplier = Public.wave_size_rng()
if wave_size_multiplier == 0 then if wave_size_multiplier == 0 then
log('Attacks: ' .. 'Aborted by chance.') log('Attacks: ' .. 'Not attempted (by chance).')
return nil return nil
else else
local group = Public.spawn_group_of_scripted_biters(2 / 3, 6, 350, wave_size_multiplier) local group = Public.spawn_group_of_scripted_biters(2 / 3, 6, 350, wave_size_multiplier)
@ -189,7 +189,7 @@ function Public.try_secondary_attack()
local wave_size_multiplier = Public.wave_size_rng() local wave_size_multiplier = Public.wave_size_rng()
if wave_size_multiplier == 0 then if wave_size_multiplier == 0 then
log('Attacks: ' .. 'Aborted by chance.') log('Attacks: ' .. 'Not attempted (by chance).')
return nil return nil
else else
local surface = game.surfaces[Common.current_destination().surface_name] local surface = game.surfaces[Common.current_destination().surface_name]
@ -216,7 +216,7 @@ function Public.try_rogue_attack()
local wave_size_multiplier = Public.wave_size_rng() local wave_size_multiplier = Public.wave_size_rng()
if wave_size_multiplier == 0 then if wave_size_multiplier == 0 then
log('Attacks: ' .. 'Aborted by chance.') log('Attacks: ' .. 'Not attempted (by chance).')
return nil return nil
else else
local surface = game.surfaces[Common.current_destination().surface_name] local surface = game.surfaces[Common.current_destination().surface_name]

View File

@ -2014,10 +2014,6 @@ local function event_on_built_entity(event)
memory.players_to_last_landmine_placement_tick[player.index] = game.tick memory.players_to_last_landmine_placement_tick[player.index] = game.tick
end end
if entity.type == 'entity-ghost' and entity.force and entity.force.valid then
entity.time_to_live = 12 * 60 * 60
end
if memory.boat and memory.boat.surface_name and player.surface == game.surfaces[memory.boat.surface_name] and entity.valid and entity.position then if memory.boat and memory.boat.surface_name and player.surface == game.surfaces[memory.boat.surface_name] and entity.valid and entity.position then
if (entity.type and (entity.type == 'underground-belt')) or (entity.name == 'entity-ghost' and entity.ghost_type and (entity.ghost_type == 'underground-belt')) then if (entity.type and (entity.type == 'underground-belt')) or (entity.name == 'entity-ghost' and entity.ghost_type and (entity.ghost_type == 'underground-belt')) then
if Boats.on_boat(memory.boat, entity.position) then if Boats.on_boat(memory.boat, entity.position) then

View File

@ -1462,7 +1462,7 @@ function Public.silo_insta_update()
if dynamic_data.rocketsilochargedbools and (not dynamic_data.rocketsilochargedbools[i]) then if dynamic_data.rocketsilochargedbools and (not dynamic_data.rocketsilochargedbools[i]) then
dynamic_data.rocketsilochargedbools[i] = true dynamic_data.rocketsilochargedbools[i] = true
local inv = silo.get_inventory(defines.inventory.assembling_machine_input) local inv = silo.get_inventory(defines.inventory.assembling_machine_input)
inv.insert { name = 'rocket-control-unit', count = 10 } inv.insert { name = 'processing-unit', count = 10 }
inv.insert { name = 'low-density-structure', count = 10 } inv.insert { name = 'low-density-structure', count = 10 }
inv.insert { name = 'rocket-fuel', count = 10 } inv.insert { name = 'rocket-fuel', count = 10 }
end end
@ -1621,14 +1621,14 @@ function Public.check_for_cliff_explosives_in_hold_wooden_chests()
queued_chests_timers[i] = nil queued_chests_timers[i] = nil
else else
local tick_tacks = { '*tick*', '*tick*', '*tack*', '*tak*', '*tik*', '*tok*' } local tick_tacks = { '*tick*', '*tick*', '*tack*', '*tak*', '*tik*', '*tok*' }
surface.create_entity( -- surface.create_entity(
{ -- {
name = 'flying-text', -- name = 'flying-text',
position = chest.position, -- position = chest.position,
text = tick_tacks[Math.random(#tick_tacks)], -- text = tick_tacks[Math.random(#tick_tacks)],
color = { r = 0.75, g = 0.75, b = 0.75 } -- color = { r = 0.75, g = 0.75, b = 0.75 }
} -- }
) -- )
end end
else else
-- we probably don't want to have it in the queue anymore if it's invalid now, do we? -- we probably don't want to have it in the queue anymore if it's invalid now, do we?

View File

@ -193,25 +193,21 @@ function Public.parrot_speak(force, message)
Server.to_discord_embed_raw({ '', '[' .. memory.name .. '] ', { 'pirates.notify_parrot' }, ' ', message }, true) Server.to_discord_embed_raw({ '', '[' .. memory.name .. '] ', { 'pirates.notify_parrot' }, ' ', message }, true)
end end
function Public.flying_text(surface, position, text) function Public.flying_text(player, position, text)
surface.create_entity( player.create_local_flying_text {
{ name = 'flying-text',
name = 'flying-text', position = { position.x - 0.7, position.y - 3.05 },
position = { position.x - 0.7, position.y - 3.05 }, text = text
text = text }
}
)
end end
function Public.flying_text_small(surface, position, text) --differs just in the location of the text, more suitable for small things like '+' function Public.flying_text_small(player, position, text) --differs just in the location of the text, more suitable for small things like '+'
surface.create_entity( player.create_local_flying_text {
{ name = 'flying-text',
name = 'flying-text', position = { position.x - 0.08, position.y - 1.5 },
position = { position.x - 0.08, position.y - 1.5 }, -- position = {position.x - 0.06, position.y - 1.5},
-- position = {position.x - 0.06, position.y - 1.5}, text = text
text = text }
}
)
end end
function Public.processed_loot_data(raw_data) function Public.processed_loot_data(raw_data)
@ -405,9 +401,9 @@ function Public.give(player, stacks, spill_position, short_form, spill_surface,
if #stacks2 > 1 then if #stacks2 > 1 then
text2 = '(' .. text2 .. ')' text2 = '(' .. text2 .. ')'
end end
Public.flying_text(spill_surface, flying_text_position, text1 .. ' [font=count-font]' .. text2 .. '[/font]') Public.flying_text(player, flying_text_position, text1 .. ' [font=count-font]' .. text2 .. '[/font]')
else else
Public.flying_text(spill_surface, flying_text_position, text1) Public.flying_text(player, flying_text_position, text1)
end end
end end
@ -728,7 +724,6 @@ function Public.new_healthbar(text, target_entity, max_health, optional_id, heal
text = '', text = '',
color = { 255, 255, 255 }, color = { 255, 255, 255 },
scale = 1.2 + size * 2, scale = 1.2 + size * 2,
render_layer = 'light-effect',
target = target_entity, target = target_entity,
target_offset = { 0, -3.6 - size * 0.6 + extra_offset }, target_offset = { 0, -3.6 - size * 0.6 + extra_offset },
surface = target_entity.surface, surface = target_entity.surface,
@ -1691,10 +1686,8 @@ function Public.get_item_blacklist(tier)
-- blacklist['productivity-module-3'] = true -- blacklist['productivity-module-3'] = true
-- blacklist['efficiency-module-3'] = true -- blacklist['efficiency-module-3'] = true
-- blacklist['space-science-pack'] = true -- blacklist['space-science-pack'] = true
-- blacklist['rocket-control-unit'] = true
blacklist['artillery-wagon'] = true blacklist['artillery-wagon'] = true
blacklist['artillery-turret'] = true blacklist['artillery-turret'] = true
blacklist['artillery-targeting-remote'] = true
-- blacklist['uranium-cannon-shell'] = true -- blacklist['uranium-cannon-shell'] = true
-- blacklist['explosive-uranium-cannon-shell'] = true -- blacklist['explosive-uranium-cannon-shell'] = true
blacklist['satellite'] = true blacklist['satellite'] = true
@ -1752,20 +1745,20 @@ function Public.get_random_dictionary_entry(t, key)
end end
end end
-- Used to connect multi-surface poles -- Used to connect multi-surface poles. NOTE: Now that Factorio 2.0 has defines.wire_origin.script, perhaps we don't need to worry about overflowing the number of connections anymore?
function Public.force_connect_poles(pole1, pole2) function Public.force_connect_poles(pole1, pole2)
if not pole1 then if not pole1 then return end
return if not pole1.valid then return end
end if not pole2 then return end
if not pole1.valid then if not pole2.valid then return end
return
end local pole1_connector = pole1.get_wire_connector(defines.wire_connector_id.pole_copper, true)
if not pole2 then local pole2_connector = pole2.get_wire_connector(defines.wire_connector_id.pole_copper, true)
return
end if not pole1_connector then return end
if not pole2.valid then if not pole1_connector.valid then return end
return if not pole2_connector then return end
end if not pole2_connector.valid then return end
-- force connections for testing (by placing many poles around the substations) -- force connections for testing (by placing many poles around the substations)
-- for _, e in pairs(pole1.surface.find_entities_filtered{type="electric-pole", position = pole1.position, radius = 10}) do -- for _, e in pairs(pole1.surface.find_entities_filtered{type="electric-pole", position = pole1.position, radius = 10}) do
@ -1777,34 +1770,34 @@ function Public.force_connect_poles(pole1, pole2)
-- end -- end
-- NOTE: "connect_neighbour" returns false when the entities are already connected as well -- NOTE: "connect_neighbour" returns false when the entities are already connected as well
pole1.disconnect_neighbour(pole2) pole1_connector.disconnect_from(pole2_connector)
local success = pole1.connect_neighbour(pole2) local success = pole1_connector.connect_to(pole2_connector, false, defines.wire_origin.script)
if success then if success then
return return
end end
local pole1_neighbours = pole1.neighbours['copper'] local pole1_connections = pole1_connector.connections
local pole2_neighbours = pole2.neighbours['copper'] local pole2_connections = pole2_connector.connections
-- try avoiding disconnecting more poles than needed -- try avoiding disconnecting more poles than needed
local disconnect_from_pole1 = false local disconnect_from_pole1 = false
local disconnect_from_pole2 = false local disconnect_from_pole2 = false
if #pole1_neighbours >= #pole2_neighbours then if #pole1_connections >= #pole2_connections then
disconnect_from_pole1 = true disconnect_from_pole1 = true
end end
if #pole2_neighbours >= #pole1_neighbours then if #pole2_connections >= #pole1_connections then
disconnect_from_pole2 = true disconnect_from_pole2 = true
end end
if disconnect_from_pole1 then if disconnect_from_pole1 then
-- Prioritise disconnecting last connections as those are most likely redundant (at least for holds, although even then it's not always the case) -- Prioritise disconnecting last connections as those are most likely redundant (at least for holds, although even then it's not always the case)
for i = #pole1_neighbours, 1, -1 do for i = #pole1_connections, 1, -1 do
local e = pole1_neighbours[i] local c = pole1_connections[i]
-- only disconnect poles from same surface -- only disconnect poles from same surface
if e and e.valid and e.surface.name == pole1.surface.name then if c and c.valid and c.owner and c.owner.valid and c.owner.surface.name == pole1.owner.surface.name then
pole1.disconnect_neighbour(e) pole1_connector.disconnect_from(c)
break break
end end
end end
@ -1812,17 +1805,17 @@ function Public.force_connect_poles(pole1, pole2)
if disconnect_from_pole2 then if disconnect_from_pole2 then
-- Prioritise disconnecting last connections as those are most likely redundant (at least for holds, although even then it's not always the case) -- Prioritise disconnecting last connections as those are most likely redundant (at least for holds, although even then it's not always the case)
for i = #pole2_neighbours, 1, -1 do for i = #pole2_connections, 1, -1 do
local e = pole2_neighbours[i] local c = pole2_connections[i]
-- only disconnect poles from same surface -- only disconnect poles from same surface
if e and e.valid and e.surface.name == pole2.surface.name then if c and c.valid and c.owner and c.owner.valid and c.owner.surface.name == pole2.owner.surface.name then
pole2.disconnect_neighbour(e) pole2_connector.disconnect_from(c)
break break
end end
end end
end end
local success2 = pole1.connect_neighbour(pole2) local success2 = pole1_connector.connect_to(pole2_connector, false, defines.wire_origin.script)
if not success2 then if not success2 then
-- This can happen if in future pole reach connection limit(5) with poles from other surfaces -- This can happen if in future pole reach connection limit(5) with poles from other surfaces
log("Error: power fix didn't work") log("Error: power fix didn't work")
@ -1849,7 +1842,7 @@ end
function Public.replace_unwalkable_tiles(surface, position, width, height) function Public.replace_unwalkable_tiles(surface, position, width, height)
local area = { left_top = { position.x - width / 2, position.y - height / 2 }, right_bottom = { position.x + width / 2 + 0.5, position.y + height / 2 + 0.5 } } local area = { left_top = { position.x - width / 2, position.y - height / 2 }, right_bottom = { position.x + width / 2 + 0.5, position.y + height / 2 + 0.5 } }
local existing = surface.find_tiles_filtered { area = area, collision_mask = 'water-tile' } local existing = surface.find_tiles_filtered { area = area, collision_mask = 'water_tile' }
if not existing then if not existing then
return return
end end

View File

@ -1068,7 +1068,6 @@ function Public.reset_crew_and_enemy_force(id)
-- crew_force.technologies['efficiency-module-2'].enabled = false -- crew_force.technologies['efficiency-module-2'].enabled = false
-- crew_force.technologies['efficiency-module-3'].enabled = false -- crew_force.technologies['efficiency-module-3'].enabled = false
-- crew_force.technologies['automation-3'].enabled = false -- crew_force.technologies['automation-3'].enabled = false
-- crew_force.technologies['rocket-control-unit'].enabled = false
-- crew_force.technologies['rocket-silo'].enabled = false -- crew_force.technologies['rocket-silo'].enabled = false
-- crew_force.technologies['space-scienkce-pack'].enabled = false -- crew_force.technologies['space-scienkce-pack'].enabled = false
-- crew_force.technologies['mining-productivity-3'].enabled = false -- crew_force.technologies['mining-productivity-3'].enabled = false

View File

@ -347,13 +347,6 @@ function Public.toggle_window(player)
flow5.style.horizontal_align = 'left' flow5.style.horizontal_align = 'left'
flow5.style.bottom_margin = 5 flow5.style.bottom_margin = 5
flow5.add({
name = 'blueprints_disabled_checkbox',
type = 'checkbox',
caption = { 'pirates.gui_runs_proposal_maker_blueprints_disabled' },
state = false,
})
flow5.add({ flow5.add({
name = 'protected_checkbox', name = 'protected_checkbox',
type = 'checkbox', type = 'checkbox',
@ -370,6 +363,13 @@ function Public.toggle_window(player)
tooltip = { 'pirates.gui_runs_proposal_maker_private_tooltip' } tooltip = { 'pirates.gui_runs_proposal_maker_private_tooltip' }
}) })
flow5.add({
name = 'blueprints_disabled_checkbox',
type = 'checkbox',
caption = { 'pirates.gui_runs_proposal_maker_blueprints_disabled' },
state = false,
})
flow6 = flow5.add({ flow6 = flow5.add({
name = 'password_label', name = 'password_label',
type = 'label', type = 'label',

View File

@ -39,14 +39,14 @@ local function create_flying_text(surface, position, text)
if not surface.valid then if not surface.valid then
return return
end end
surface.create_entity( -- surface.create_entity(
{ -- {
name = 'flying-text', -- name = 'flying-text',
position = position, -- position = position,
text = text, -- text = text,
color = { r = 0.75, g = 0.75, b = 0.75 } -- color = { r = 0.75, g = 0.75, b = 0.75 }
} -- }
) -- )
if text == '...' then if text == '...' then
return return
end end
@ -60,14 +60,14 @@ local function create_kaboom(force_name, surface, position, name)
local target = position local target = position
local speed = 0.5 local speed = 0.5
if name == 'defender-capsule' or name == 'destroyer-capsule' or name == 'distractor-capsule' then if name == 'defender-capsule' or name == 'destroyer-capsule' or name == 'distractor-capsule' then
surface.create_entity( -- surface.create_entity(
{ -- {
name = 'flying-text', -- name = 'flying-text',
position = position, -- position = position,
text = '(((Sentries Engaging Target)))', -- text = '(((Sentries Engaging Target)))',
color = { r = 0.8, g = 0.0, b = 0.0 } -- color = { r = 0.8, g = 0.0, b = 0.0 }
} -- }
) -- )
local nearest_player_unit = surface.find_nearest_enemy({ position = position, max_distance = 128, force = force_name }) local nearest_player_unit = surface.find_nearest_enemy({ position = position, max_distance = 128, force = force_name })
if nearest_player_unit then if nearest_player_unit then
target = nearest_player_unit.position target = nearest_player_unit.position

View File

@ -519,7 +519,7 @@ function Public.ensure_lane_generated_up_to(lane_yvalue, x)
if type(r) == 'table' and r.text_rendering and r.text_rendering.valid then if type(r) == 'table' and r.text_rendering and r.text_rendering.valid then
for _, price_data in ipairs(Upgrades.upgrades_data[dest.static_params.upgrade_for_sale].market_item.price) do for _, price_data in ipairs(Upgrades.upgrades_data[dest.static_params.upgrade_for_sale].market_item.price) do
if price_data.name == rendering_name then if price_data.name == rendering_name then
r.text_rendering.text = Utils.bignumber_abbrevform2(price_data[2]) r.text_rendering.text = Utils.bignumber_abbrevform2(price_data.count)
break break
end end
end end

View File

@ -81,7 +81,6 @@ function Public.set_off_from_starting_dock()
local p = Utils.psum { memory.boat.position, Boats.get_scope(memory.boat).Data.crewname_rendering_position } local p = Utils.psum { memory.boat.position, Boats.get_scope(memory.boat).Data.crewname_rendering_position }
memory.boat.rendering_crewname_text = rendering.draw_text { memory.boat.rendering_crewname_text = rendering.draw_text {
text = memory.name, text = memory.name,
-- render_layer = '125', --does nothing
surface = surface, surface = surface,
target = p, target = p,
color = CoreData.colors.renderingtext_yellow, color = CoreData.colors.renderingtext_yellow,

View File

@ -53,7 +53,6 @@ Public.market_permanent_offers = {
{ price = { { name = 'coin', count = 4200 } }, offer = { type = 'give-item', item = 'speed-module-2', count = 2 } }, { price = { { name = 'coin', count = 4200 } }, offer = { type = 'give-item', item = 'speed-module-2', count = 2 } },
{ price = { { name = 'coin', count = 3000 } }, offer = { type = 'give-item', item = 'explosives', count = 50 } }, { price = { { name = 'coin', count = 3000 } }, offer = { type = 'give-item', item = 'explosives', count = 50 } },
{ price = { { name = 'coin', count = 6500 }, { name = 'steel-plate', count = 25 }, { name = 'explosives', count = 50 } }, offer = { type = 'give-item', item = 'land-mine', count = 100 } }, { price = { { name = 'coin', count = 6500 }, { name = 'steel-plate', count = 25 }, { name = 'explosives', count = 50 } }, offer = { type = 'give-item', item = 'land-mine', count = 100 } },
-- {price = {{'coin', 30000}}, offer = {type = 'give-item', item = 'artillery-targeting-remote', count = 1}},
} }
-- cheap but one-off -- cheap but one-off

View File

@ -316,7 +316,7 @@ function Public.event_on_market_item_purchased(event)
local text1 = '[color=1,1,1]+' .. thisPurchaseData.offer_giveitem_count .. '[/color] [item=' .. thisPurchaseData.offer_giveitem_name .. ']' local text1 = '[color=1,1,1]+' .. thisPurchaseData.offer_giveitem_count .. '[/color] [item=' .. thisPurchaseData.offer_giveitem_name .. ']'
local text2 = '[color=' .. flying_text_color.r .. ',' .. flying_text_color.g .. ',' .. flying_text_color.b .. '](' .. inv.get_item_count(thisPurchaseData.offer_giveitem_name) .. ')[/color]' local text2 = '[color=' .. flying_text_color.r .. ',' .. flying_text_color.g .. ',' .. flying_text_color.b .. '](' .. inv.get_item_count(thisPurchaseData.offer_giveitem_name) .. ')[/color]'
Common.flying_text(player.surface, player.position, text1 .. ' [font=count-font]' .. text2 .. '[/font]') Common.flying_text(player, player.position, text1 .. ' [font=count-font]' .. text2 .. '[/font]')
else else
local decay_param = Balance.barter_decay_parameter() local decay_param = Balance.barter_decay_parameter()
if thisPurchaseData.decay_type == 'fast_decay' then decay_param = Balance.barter_decay_parameter() ^ 3 end if thisPurchaseData.decay_type == 'fast_decay' then decay_param = Balance.barter_decay_parameter() ^ 3 end
@ -326,7 +326,7 @@ function Public.event_on_market_item_purchased(event)
local text1 = '[color=1,1,1]+' .. thisPurchaseData.offer_giveitem_count .. '[/color] [item=' .. thisPurchaseData.offer_giveitem_name .. ']' local text1 = '[color=1,1,1]+' .. thisPurchaseData.offer_giveitem_count .. '[/color] [item=' .. thisPurchaseData.offer_giveitem_name .. ']'
local text2 = '[color=' .. flying_text_color.r .. ',' .. flying_text_color.g .. ',' .. flying_text_color.b .. '](' .. inv.get_item_count(thisPurchaseData.offer_giveitem_name) .. ')[/color]' local text2 = '[color=' .. flying_text_color.r .. ',' .. flying_text_color.g .. ',' .. flying_text_color.b .. '](' .. inv.get_item_count(thisPurchaseData.offer_giveitem_name) .. ')[/color]'
Common.flying_text(player.surface, player.position, text1 .. ' [font=count-font]' .. text2 .. '[/font]') Common.flying_text(player, player.position, text1 .. ' [font=count-font]' .. text2 .. '[/font]')
--update market trades: --update market trades:
thisPurchaseData.alloffers[offer_index].offer.count = Math.max(Math.floor(thisPurchaseData.alloffers[offer_index].offer.count * decay_param), 1) thisPurchaseData.alloffers[offer_index].offer.count = Math.max(Math.floor(thisPurchaseData.alloffers[offer_index].offer.count * decay_param), 1)

View File

@ -12,7 +12,7 @@ local Hold = require 'maps.pirates.surfaces.hold'
local Cabin = require 'maps.pirates.surfaces.cabin' local Cabin = require 'maps.pirates.surfaces.cabin'
local Utils = require 'maps.pirates.utils_local' local Utils = require 'maps.pirates.utils_local'
local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum' local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
-- local _inspect = require 'utils.inspect'.inspect local _inspect = require 'utils.inspect'.inspect
-- DEV NOTE: If making boat designs that have rails, make sure the boat is placed at odd co-ordinates before blueprinting. -- DEV NOTE: If making boat designs that have rails, make sure the boat is placed at odd co-ordinates before blueprinting.
@ -824,7 +824,7 @@ local function process_entity_on_boat_unteleportable(memory, boat, newsurface, v
end end
-- @TODO: Rocket silo that is prepared to launch the rocket needs to be cloned with clone_entities instead. See: https://forums.factorio.com/viewtopic.php?f=23&t=105073&p=580968 -- @TODO: Rocket silo that is prepared to launch the rocket needs to be cloned with clone_entities instead. See: https://forums.factorio.com/viewtopic.php?f=23&t=105073&p=580968
local function process_entity_on_boat_teleportable(memory, boat, newsurface, newposition, vector, oldsurface_name, newsurface_name, electric_pole_neighbours_matrix, circuit_neighbours_matrix, e) local function process_entity_on_boat_teleportable(memory, boat, newsurface, newposition, vector, oldsurface_name, newsurface_name, wire_connections_matrix, e)
if oldsurface_name == newsurface_name then if oldsurface_name == newsurface_name then
e.teleport(vector.x, vector.y) e.teleport(vector.x, vector.y)
e.update_connections() e.update_connections()
@ -835,40 +835,26 @@ local function process_entity_on_boat_teleportable(memory, boat, newsurface, new
local p = Utils.deepcopy(e.position) local p = Utils.deepcopy(e.position)
local p2 = { x = p.x + vector.x, y = p.y + vector.y } local p2 = { x = p.x + vector.x, y = p.y + vector.y }
if e.type == 'electric-pole' then local wire_connnectors = e.get_wire_connectors(false)
for k, v in pairs(e.neighbours or {}) do
if k == 'copper' then --red and green cases handled by circuit_neighbours_matrix
if not electric_pole_neighbours_matrix[k] then electric_pole_neighbours_matrix[k] = {} end
for _, v2 in pairs(v) do
if v2 and v2.valid and v2.position then
local v2p = v2.position
if not electric_pole_neighbours_matrix[k][v2p.x] then
electric_pole_neighbours_matrix[k][v2p.x] = {}
end
if not electric_pole_neighbours_matrix[k][v2p.x][v2p.y] then
electric_pole_neighbours_matrix[k][v2p.x][v2p.y] = {}
end
electric_pole_neighbours_matrix[k][v2p.x][v2p.y][#electric_pole_neighbours_matrix[k][v2p.x][v2p.y] + 1] = { name = e.name, pos = p }
end
end
end
end
end
for _, v in pairs(e.circuit_connection_definitions or {}) do for _, v in pairs(wire_connnectors or {}) do
local e2 = v.target_entity local wire = v.wire_type
local wire = v.wire local wire_connector_id = v.wire_connector_id
local source_circuit_id = v.source_circuit_id local connections = v.connections
local target_circuit_id = v.target_circuit_id
if e2 and e2.valid and e2.position and (wire == defines.wire_type.red or wire == defines.wire_type.green) then --observed an error "Expected source_wire_id for entities with more than one wire connection" in the .connect_neighbour() function called later, so putting the red/green wire check in to try and catch it for _, c in pairs(connections or {}) do
local e2p = e2.position local c2 = c.target
if not circuit_neighbours_matrix[e2p.x] then
circuit_neighbours_matrix[e2p.x] = {} if c2 and c2.valid and c2.owner and c2.owner.valid and c2.owner.position then
local e2p = c2.owner.position
if not wire_connections_matrix[e2p.x] then
wire_connections_matrix[e2p.x] = {}
end
if not wire_connections_matrix[e2p.x][e2p.y] then
wire_connections_matrix[e2p.x][e2p.y] = {}
end
wire_connections_matrix[e2p.x][e2p.y][#wire_connections_matrix[e2p.x][e2p.y] + 1] = { name = e.name, pos = p, wire = wire, wire_connector_id = wire_connector_id } --flip since we will read these backwards
end end
if not circuit_neighbours_matrix[e2p.x][e2p.y] then
circuit_neighbours_matrix[e2p.x][e2p.y] = {}
end
circuit_neighbours_matrix[e2p.x][e2p.y][#circuit_neighbours_matrix[e2p.x][e2p.y] + 1] = { name = e.name, pos = p, wire = wire, source_circuit_id = target_circuit_id, target_circuit_id = source_circuit_id } --flip since we will read these backwards
end end
end end
@ -884,14 +870,11 @@ local function process_entity_on_boat_teleportable(memory, boat, newsurface, new
if e == boat.upstairs_pole then if e == boat.upstairs_pole then
boat.upstairs_pole = ee boat.upstairs_pole = ee
if boat.downstairs_poles and boat.downstairs_poles[1] then if boat.downstairs_poles and boat.downstairs_poles[1] and boat.downstairs_poles[1][1] then
-- Remove previous connection, before connecting it with the new clone to avoid sometimes having to remove wire connection because of limit
e.disconnect_neighbour(boat.downstairs_poles[1][1])
Common.force_connect_poles(boat.upstairs_pole, boat.downstairs_poles[1][1]) Common.force_connect_poles(boat.upstairs_pole, boat.downstairs_poles[1][1])
end end
end end
local pet_biter_data = memory.pet_biters[e.unit_number] local pet_biter_data = memory.pet_biters[e.unit_number]
if pet_biter_data then if pet_biter_data then
local owner = pet_biter_data.pet_owner local owner = pet_biter_data.pet_owner
@ -964,44 +947,28 @@ local function process_entity_on_boat_teleportable(memory, boat, newsurface, new
end end
end end
if circuit_neighbours_matrix[p.x] and circuit_neighbours_matrix[p.x][p.y] then if wire_connections_matrix[p.x] and wire_connections_matrix[p.x][p.y] then
for _, v2 in pairs(circuit_neighbours_matrix[p.x][p.y]) do log(_inspect(wire_connections_matrix[p.x][p.y]))
for _, v2 in pairs(wire_connections_matrix[p.x][p.y]) do
log(_inspect(v2.pos))
local p3 = { x = v2.pos.x + vector.x, y = v2.pos.y + vector.y } local p3 = { x = v2.pos.x + vector.x, y = v2.pos.y + vector.y }
local e3s = newsurface.find_entities_filtered { local e3s = newsurface.find_entities_filtered {
name = v2.name, name = v2.name,
position = p3, position = p3,
radius = 0.01, radius = 0.01,
} }
log(#e3s)
if e3s and #e3s > 0 then if e3s and #e3s > 0 then
local e3 = e3s[1] local e3 = e3s[1]
if e3 and e3.valid then if e3 and e3.valid then
ee.connect_neighbour { wire = v2.wire, target_entity = e3, source_circuit_id = v2.source_circuit_id, target_circuit_id = v2.target_circuit_id } log(_inspect(e3.name))
end local ee_connector = ee.get_wire_connector(v2.wire_connector_id, true)
end local e3_connector = e3.get_wire_connector(v2.wire_connector_id, true)
end
end
if ee.type == 'electric-pole' then if ee_connector and e3_connector and ee_connector.valid and e3_connector.valid then
for k, v in pairs(electric_pole_neighbours_matrix or {}) do log('connecting')
if v[p.x] and v[p.x][p.y] then local succeeded = ee_connector.connect_to(e3_connector, false)
for _, v2 in pairs(v[p.x][p.y]) do log(succeeded)
local p3 = { x = v2.pos.x + vector.x, y = v2.pos.y + vector.y }
local e3s = newsurface.find_entities_filtered {
name = v2.name,
position = p3,
radius = 0.01,
}
if e3s and #e3s > 0 then
local e3 = e3s[1]
if e3 and e3.valid then
if k == 'copper' then
ee.connect_neighbour(e3)
-- elseif k == 'red' then
-- ee.connect_neighbour{wire = defines.wire_type.red, target_entity = e3}
-- elseif k == 'green' then
-- ee.connect_neighbour{wire = defines.wire_type.green, target_entity = e3}
end
end
end end
end end
end end
@ -1010,7 +977,7 @@ local function process_entity_on_boat_teleportable(memory, boat, newsurface, new
end end
local function process_entity_on_boat(memory, boat, newsurface, newposition, vector, players_just_offside, oldsurface_name, newsurface_name, unique_entities_list, electric_pole_neighbours_matrix, circuit_neighbours_matrix, e) local function process_entity_on_boat(memory, boat, newsurface, newposition, vector, players_just_offside, oldsurface_name, newsurface_name, unique_entities_list, wire_connections_matrix, e)
if e and e.valid and (not Utils.contains(unique_entities_list, e)) then if e and e.valid and (not Utils.contains(unique_entities_list, e)) then
unique_entities_list[#unique_entities_list + 1] = e unique_entities_list[#unique_entities_list + 1] = e
local name = e.name local name = e.name
@ -1032,7 +999,7 @@ local function process_entity_on_boat(memory, boat, newsurface, newposition, vec
elseif Utils.contains(CoreData.unteleportable_names, name) or (name == 'entity-ghost' and Utils.contains(CoreData.unteleportable_names, e.ghost_name)) then elseif Utils.contains(CoreData.unteleportable_names, name) or (name == 'entity-ghost' and Utils.contains(CoreData.unteleportable_names, e.ghost_name)) then
process_entity_on_boat_unteleportable(memory, boat, newsurface, vector, players_just_offside, oldsurface_name, newsurface_name, e, name) process_entity_on_boat_unteleportable(memory, boat, newsurface, vector, players_just_offside, oldsurface_name, newsurface_name, e, name)
else else
process_entity_on_boat_teleportable(memory, boat, newsurface, newposition, vector, oldsurface_name, newsurface_name, electric_pole_neighbours_matrix, circuit_neighbours_matrix, e) process_entity_on_boat_teleportable(memory, boat, newsurface, newposition, vector, oldsurface_name, newsurface_name, wire_connections_matrix, e)
end end
end end
end end
@ -1152,7 +1119,6 @@ local function teleport_handle_renderings(boat, oldsurface_name, newsurface_name
boat.rendering_crewname_text.destroy() boat.rendering_crewname_text.destroy()
boat.rendering_crewname_text = rendering.draw_text { boat.rendering_crewname_text = rendering.draw_text {
text = memory.name, text = memory.name,
-- render_layer = '125', --does nothing
surface = newsurface, surface = newsurface,
target = p, target = p,
color = CoreData.colors.renderingtext_yellow, color = CoreData.colors.renderingtext_yellow,
@ -1425,13 +1391,12 @@ function Public.teleport_boat(boat, newsurface_name, newposition, new_floor_tile
local electric_pole_neighbours_matrix = {} local wire_connections_matrix = {}
local circuit_neighbours_matrix = {}
-- local underground_belt_neighbours_matrix = {} -- local underground_belt_neighbours_matrix = {}
for i = 1, #entities_on_boat do for i = 1, #entities_on_boat do
local e = entities_on_boat[i] local e = entities_on_boat[i]
process_entity_on_boat(memory, boat, newsurface, newposition, vector, players_just_offside, oldsurface_name, newsurface_name, unique_entities_list, electric_pole_neighbours_matrix, circuit_neighbours_matrix, e) process_entity_on_boat(memory, boat, newsurface, newposition, vector, players_just_offside, oldsurface_name, newsurface_name, unique_entities_list, wire_connections_matrix, e)
end end
@ -1485,7 +1450,7 @@ function Public.clear_fluid_from_ship_tanks(idx)
end end
end end
-- Players can brick power by removing wire connections themselves (even between surfaces) with "shift + LMB" when clicking on pole -- At least before Factorio 2.0, players can brick power by removing wire connections themselves (even between surfaces) with "shift + LMB" when clicking on pole
function Public.force_reconnect_boat_poles() function Public.force_reconnect_boat_poles()
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
local boat = memory.boat local boat = memory.boat
@ -1493,17 +1458,11 @@ function Public.force_reconnect_boat_poles()
if boat.downstairs_poles then if boat.downstairs_poles then
if boat.downstairs_poles[1] then if boat.downstairs_poles[1] then
Common.force_connect_poles(boat.upstairs_pole, boat.downstairs_poles[1][1]) Common.force_connect_poles(boat.upstairs_pole, boat.downstairs_poles[1][1])
-- Optional connection
boat.downstairs_poles[1][1].connect_neighbour(boat.downstairs_poles[1][2])
end end
for i = 2, memory.hold_surface_count do for i = 2, memory.hold_surface_count do
if boat.downstairs_poles[i] then if boat.downstairs_poles[i] then
Common.force_connect_poles(boat.downstairs_poles[i][1], boat.downstairs_poles[i - 1][2]) Common.force_connect_poles(boat.downstairs_poles[i][1], boat.downstairs_poles[i - 1][2])
-- Optional connection
boat.downstairs_poles[i][1].connect_neighbour(boat.downstairs_poles[i][2])
end end
end end
end end

View File

@ -72,13 +72,15 @@ function Public.initialise_cached_quest_structure(position, quest_structure_type
scale = 1.5, scale = 1.5,
font = 'default-game', font = 'default-game',
alignment = 'right', alignment = 'right',
text = '',
} }
local rendering2 = rendering.draw_sprite { local rendering2 = rendering.draw_sprite {
sprite = 'item/' .. entry_price.name, sprite = 'item/' .. entry_price.name,
surface = surface, surface = surface,
target = { x = position.x + 3.5, y = position.y - 0.65 }, target = { x = position.x + 3.5, y = position.y - 0.65 },
x_scale = 1.5, x_scale = 1.5,
y_scale = 1.5 y_scale = 1.5,
text = '',
} }
local rendering3 = rendering.draw_text { local rendering3 = rendering.draw_text {
surface = surface, surface = surface,
@ -140,6 +142,7 @@ function Public.initialise_cached_quest_structure(position, quest_structure_type
scale = 1.5, scale = 1.5,
font = 'default-game', font = 'default-game',
alignment = 'right', alignment = 'right',
text = '',
} }
local rendering2 = rendering.draw_sprite { local rendering2 = rendering.draw_sprite {
sprite = 'item/' .. entry_price.name, sprite = 'item/' .. entry_price.name,

View File

@ -300,9 +300,8 @@ function Public.create_cabin_surface()
{ {
color = { 60, 255, 124 }, color = { 60, 255, 124 },
scale = 1.6, scale = 1.6,
render_layer = 'light-effect',
target = e, target = e,
target_offset = { 0, -2.7 }, target_offset = { 0, -6 },
surface = e.surface, surface = e.surface,
alignment = 'center', alignment = 'center',
text = "Captain's Market" text = "Captain's Market"

View File

@ -118,7 +118,7 @@ function Public.spawn_ghosts(destination, points_to_avoid)
ghost.ghostobject_rendering = rendering.draw_sprite { ghost.ghostobject_rendering = rendering.draw_sprite {
surface = surface, surface = surface,
target = p, target = p,
sprite = 'utility/ghost_time_to_live_modifier_icon', sprite = 'utility/create_ghost_on_entity_death_modifier_icon',
render_layer = '125', render_layer = '125',
x_scale = 1, x_scale = 1,
y_scale = 1, y_scale = 1,
@ -292,7 +292,7 @@ function Public.spawn_silo_setup(points_to_avoid)
silo.rotatable = false silo.rotatable = false
silo.operable = false silo.operable = false
if i == 1 then if i == 1 then
silo.auto_launch = true -- silo.auto_launch = true
Common.new_healthbar(true, silo, Balance.silo_max_hp, nil, Balance.silo_max_hp, 0.6, -2, destination.dynamic_data) Common.new_healthbar(true, silo, Balance.silo_max_hp, nil, Balance.silo_max_hp, 0.6, -2, destination.dynamic_data)
else else
silo.destructible = false silo.destructible = false