mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-25 21:29:06 +02:00
Merge branch 'develop' into stylua-ignore
This commit is contained in:
commit
c8c52e9f1a
@ -111,7 +111,7 @@ local artillery_target_entities = {
|
||||
'car',
|
||||
'radar',
|
||||
'lab',
|
||||
'furnace',
|
||||
'stone-furnace',
|
||||
'locomotive',
|
||||
'cargo-wagon',
|
||||
'fluid-wagon',
|
||||
@ -120,7 +120,7 @@ local artillery_target_entities = {
|
||||
'laser-turret',
|
||||
'gun-turret',
|
||||
'flamethrower-turret',
|
||||
'silo',
|
||||
'rocket-silo',
|
||||
'spidertron'
|
||||
}
|
||||
|
||||
|
@ -677,9 +677,17 @@ local function construct_doors(car)
|
||||
for _, x in pairs({ area.left_top.x - 1.5, area.right_bottom.x + 1.5 }) do
|
||||
local p = { x = x, y = area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5) }
|
||||
if p.x < 0 then
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x + 0.5, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x + 0.5, y = p.y - 0.5 } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x + 0.5, y = p.y - 1 } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x - 0.5, y = p.y - 1 } } }, true)
|
||||
else
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x - 0.5, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x - 1, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x, y = p.y - 0.5 } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x - 1, y = p.y - 0.5 } } }, true)
|
||||
end
|
||||
local e =
|
||||
surface.create_entity(
|
||||
|
@ -484,9 +484,17 @@ local function construct_wagon_doors(icw, wagon)
|
||||
for _, x in pairs({ area.left_top.x - 1.5, area.right_bottom.x + 1.5 }) do
|
||||
local p = { x = x, y = area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5) }
|
||||
if p.x < 0 then
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x + 0.5, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x + 0.5, y = p.y - 0.5 } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x + 0.5, y = p.y - 1 } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x - 0.5, y = p.y - 1 } } }, true)
|
||||
else
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x - 0.5, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x - 1, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x, y = p.y - 0.5 } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x - 1, y = p.y - 0.5 } } }, true)
|
||||
end
|
||||
local e =
|
||||
surface.create_entity(
|
||||
|
@ -1030,8 +1030,8 @@ local function update_raw()
|
||||
stateful.objectives_completed.randomized_zone = true
|
||||
stateful.objectives_time_spent.randomized_zone = tick
|
||||
play_achievement_unlocked()
|
||||
Alert.alert_all_players(100, 'Objective: **breach zone** has been complete!')
|
||||
Server.to_discord_embed('Objective: **breach zone** has been complete!')
|
||||
Alert.alert_all_players(100, 'Objective: [color=blue]Breach zone[/color] has been completed!')
|
||||
Server.to_discord_embed('Objective: **Breach zone** has been completed!')
|
||||
stateful.objectives_completed_count = stateful.objectives_completed_count + 1
|
||||
end
|
||||
end
|
||||
@ -1044,8 +1044,8 @@ local function update_raw()
|
||||
stateful.objectives_time_spent.randomized_wave = tick
|
||||
|
||||
play_achievement_unlocked()
|
||||
Alert.alert_all_players(100, 'Objective: **survive until wave** has been complete!')
|
||||
Server.to_discord_embed('Objective: **survive until wave** has been complete!')
|
||||
Alert.alert_all_players(100, 'Objective: [color=blue]Wave survival[/color] has been completed!')
|
||||
Server.to_discord_embed('Objective: **Wave survival** has been completed!')
|
||||
stateful.objectives_completed_count = stateful.objectives_completed_count + 1
|
||||
end
|
||||
end
|
||||
@ -1069,8 +1069,8 @@ local function update_raw()
|
||||
if not stateful.objectives_completed.supplies then
|
||||
stateful.objectives_completed.supplies = true
|
||||
stateful.objectives_time_spent.supplies = tick
|
||||
Alert.alert_all_players(100, 'Objective: **produce 3 items multiple times** has been complete!')
|
||||
Server.to_discord_embed('Objective: **produce 3 items multiple times** has been complete!')
|
||||
Alert.alert_all_players(100, 'Objective: [color=blue]Produce items[/color] has been completed!')
|
||||
Server.to_discord_embed('Objective: **Produce items** has been completed!')
|
||||
play_achievement_unlocked()
|
||||
stateful.objectives_completed_count = stateful.objectives_completed_count + 1
|
||||
end
|
||||
@ -1097,8 +1097,8 @@ local function update_raw()
|
||||
stateful.objectives_completed.single_item = true
|
||||
stateful.objectives_time_spent.single_item = tick
|
||||
play_achievement_unlocked()
|
||||
Alert.alert_all_players(100, 'Objective: **produce an item multiple times** has been completed!')
|
||||
Server.to_discord_embed('Objective: **produce an item multiple times** has been completed!')
|
||||
Alert.alert_all_players(100, 'Objective: [color=blue]Produce item[/color] has been completed!')
|
||||
Server.to_discord_embed('Objective: **Produce item** has been completed!')
|
||||
stateful.objectives_completed_count = stateful.objectives_completed_count + 1
|
||||
end
|
||||
end
|
||||
@ -1194,8 +1194,8 @@ local function update_raw()
|
||||
if completed and completed == true and not stateful.objectives_completed[objective_name] then
|
||||
stateful.objectives_completed[objective_name] = true
|
||||
stateful.objectives_time_spent[objective_name] = tick
|
||||
Alert.alert_all_players(100, 'Objective: **' .. objective_name .. '** has been completed!')
|
||||
Server.to_discord_embed('Objective: **' .. objective_name .. '** has been completed!')
|
||||
Alert.alert_all_players(100, 'Objective: [color=blue]' .. objective.discord .. '[/color] has been completed!')
|
||||
Server.to_discord_embed('Objective: **' .. objective.discord .. '** has been completed!')
|
||||
play_achievement_unlocked()
|
||||
stateful.objectives_completed_count = stateful.objectives_completed_count + 1
|
||||
end
|
||||
|
@ -958,51 +958,63 @@ local function get_random_objectives()
|
||||
local items = {
|
||||
{
|
||||
name = 'single_item',
|
||||
token = empty_token
|
||||
token = empty_token,
|
||||
discord = 'Produce item'
|
||||
},
|
||||
{
|
||||
name = 'killed_enemies',
|
||||
token = killed_enemies_token
|
||||
token = killed_enemies_token,
|
||||
discord = 'Kill enemies'
|
||||
},
|
||||
{
|
||||
name = 'killed_enemies_type',
|
||||
token = killed_enemies_type_token
|
||||
token = killed_enemies_type_token,
|
||||
discord = 'Kill enemies of a specific type'
|
||||
},
|
||||
{
|
||||
name = 'handcrafted_items',
|
||||
token = handcrafted_items_token
|
||||
token = handcrafted_items_token,
|
||||
discord = 'Craft items'
|
||||
},
|
||||
{
|
||||
name = 'handcrafted_items_any',
|
||||
token = handcrafted_items_any_token
|
||||
token = handcrafted_items_any_token,
|
||||
discord = 'Craft any items'
|
||||
},
|
||||
{
|
||||
name = 'cast_spell',
|
||||
token = cast_spell_token
|
||||
token = cast_spell_token,
|
||||
discord = 'Cast a spell'
|
||||
},
|
||||
{
|
||||
name = 'launch_item',
|
||||
token = launch_item_token
|
||||
token = launch_item_token,
|
||||
discord = 'Launch an item'
|
||||
},
|
||||
{
|
||||
name = 'cast_spell_any',
|
||||
token = cast_spell_any_token
|
||||
token = cast_spell_any_token,
|
||||
discord = 'Cast any spell'
|
||||
},
|
||||
{
|
||||
name = 'research_level_selection',
|
||||
token = research_level_selection_token
|
||||
token = research_level_selection_token,
|
||||
discord = 'Research a specific technology'
|
||||
},
|
||||
{
|
||||
name = 'locomotive_market_coins_spent',
|
||||
token = locomotive_market_coins_spent_token
|
||||
token = locomotive_market_coins_spent_token,
|
||||
discord = 'Spend coins at the market'
|
||||
},
|
||||
{
|
||||
name = 'minerals_farmed',
|
||||
token = minerals_farmed_token
|
||||
token = minerals_farmed_token,
|
||||
discord = 'Mine minerals'
|
||||
},
|
||||
{
|
||||
name = 'rockets_launched',
|
||||
token = rockets_launched_token
|
||||
token = rockets_launched_token,
|
||||
discord = 'Launch rockets'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,8 @@ local this = {
|
||||
settings = {
|
||||
is_enabled = false,
|
||||
offline_players_surface_removal = false,
|
||||
active_surface_index = nil, -- needs to be set else this will fail
|
||||
required_online_time = 18000, -- nearest prime to 5 minutes in ticks
|
||||
active_surface_index = nil, -- needs to be set else this will fail
|
||||
required_online_time = 18000, -- nearest prime to 5 minutes in ticks
|
||||
clear_player_after_tick = 108000 -- nearest prime to 30 minutes in ticks
|
||||
},
|
||||
offline_players = {}
|
||||
@ -17,7 +17,7 @@ local this = {
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function(tbl)
|
||||
function (tbl)
|
||||
this = tbl
|
||||
end
|
||||
)
|
||||
@ -43,8 +43,6 @@ function Public.dump_expired_players()
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
local player_inv = {}
|
||||
local items = {}
|
||||
if #this.offline_players > 0 then
|
||||
for i = 1, #this.offline_players, 1 do
|
||||
if this.offline_players[i] and this.offline_players[i].index then
|
||||
@ -54,8 +52,11 @@ function Public.dump_expired_players()
|
||||
remove(this.offline_players, i)
|
||||
else
|
||||
if this.offline_players[i].tick < tick then
|
||||
local name = this.offline_players[i].name
|
||||
player_inv[1] = target.get_inventory(defines.inventory.character_main)
|
||||
local player_inv = {}
|
||||
local items = {}
|
||||
|
||||
local name = target.name
|
||||
player_inv[1] = target.get_main_inventory()
|
||||
player_inv[2] = target.get_inventory(defines.inventory.character_armor)
|
||||
player_inv[3] = target.get_inventory(defines.inventory.character_guns)
|
||||
player_inv[4] = target.get_inventory(defines.inventory.character_ammo)
|
||||
@ -64,25 +65,32 @@ function Public.dump_expired_players()
|
||||
Event.raise(this.events.remove_surface, { target = target })
|
||||
end
|
||||
|
||||
if target.get_item_count() == 0 then -- if the player has zero items, don't do anything
|
||||
local found_items = false
|
||||
for index = 1, 5, 1 do
|
||||
if player_inv[index] and player_inv[index].valid and player_inv[index].get_item_count() ~= 0 then
|
||||
found_items = true
|
||||
end
|
||||
end
|
||||
|
||||
if not found_items then -- if the player has zero items, don't do anything
|
||||
remove(this.offline_players, i)
|
||||
goto final
|
||||
end
|
||||
|
||||
local pos = game.forces.player.get_spawn_position(surface)
|
||||
local e =
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'character',
|
||||
position = pos,
|
||||
force = 'neutral'
|
||||
}
|
||||
)
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'character',
|
||||
position = pos,
|
||||
force = 'neutral'
|
||||
}
|
||||
)
|
||||
if not e or not e.valid then
|
||||
break
|
||||
end
|
||||
|
||||
local inv = e.get_inventory(defines.inventory.character_main)
|
||||
local inv = e.get_main_inventory()
|
||||
if not inv then
|
||||
break
|
||||
end
|
||||
@ -90,9 +98,9 @@ function Public.dump_expired_players()
|
||||
---@diagnostic disable-next-line: assign-type-mismatch
|
||||
e.character_inventory_slots_bonus = #player_inv[1]
|
||||
for ii = 1, 5, 1 do
|
||||
if player_inv[ii].valid then
|
||||
if player_inv[ii] and player_inv[ii].valid then
|
||||
for iii = 1, #player_inv[ii], 1 do
|
||||
if player_inv[ii][iii].valid then
|
||||
if player_inv[ii][iii] and player_inv[ii][iii].valid then
|
||||
insert(items, player_inv[ii][iii])
|
||||
end
|
||||
end
|
||||
@ -117,7 +125,7 @@ function Public.dump_expired_players()
|
||||
end
|
||||
|
||||
for ii = 1, 5, 1 do
|
||||
if player_inv[ii].valid then
|
||||
if player_inv[ii] and player_inv[ii].valid then
|
||||
player_inv[ii].clear()
|
||||
end
|
||||
end
|
||||
@ -184,7 +192,7 @@ Event.on_nth_tick(tick_frequency, Public.dump_expired_players)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_pre_player_left_game,
|
||||
function(event)
|
||||
function (event)
|
||||
if not this.settings.is_enabled then
|
||||
return
|
||||
end
|
||||
|
@ -164,16 +164,21 @@ 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 target = Gui.get_data(element)
|
||||
local data = Gui.get_data(element)
|
||||
if not data then return end
|
||||
|
||||
if not target or not target.valid then
|
||||
if player.controller_type == defines.controllers.remote then
|
||||
return
|
||||
end
|
||||
|
||||
if target.character ~= nil then target = target.character end
|
||||
player.centered_on = target
|
||||
player.set_controller({
|
||||
type = defines.controllers.remote,
|
||||
position = data.position,
|
||||
surface = player.surface,
|
||||
zoom = 4
|
||||
})
|
||||
end
|
||||
|
||||
local close_alert = Public.close_alert
|
||||
@ -290,7 +295,7 @@ function Public.alert_all_players_location(player, message, color, duration)
|
||||
style = 'slot_button'
|
||||
}
|
||||
|
||||
Gui.set_data(sprite, player)
|
||||
Gui.set_data(sprite, player.position)
|
||||
|
||||
local label =
|
||||
container.add {
|
||||
|
@ -583,6 +583,25 @@ function Public:callback(func)
|
||||
end
|
||||
end
|
||||
|
||||
local directions = {
|
||||
[0] = 'defines.direction.north',
|
||||
[1] = 'defines.direction.northnortheast',
|
||||
[2] = 'defines.direction.northeast',
|
||||
[3] = 'defines.direction.eastnortheast',
|
||||
[4] = 'defines.direction.east',
|
||||
[5] = 'defines.direction.eastsoutheast',
|
||||
[6] = 'defines.direction.southeast',
|
||||
[7] = 'defines.direction.southsoutheast',
|
||||
[8] = 'defines.direction.south',
|
||||
[9] = 'defines.direction.southsouthwest',
|
||||
[10] = 'defines.direction.southwest',
|
||||
[11] = 'defines.direction.westsouthwest',
|
||||
[12] = 'defines.direction.west',
|
||||
[13] = 'defines.direction.westnorthwest',
|
||||
[14] = 'defines.direction.northwest',
|
||||
[15] = 'defines.direction.northnorthwest',
|
||||
}
|
||||
|
||||
Public.new('get', 'Hover over an object to get its name.')
|
||||
:require_admin()
|
||||
:add_parameter('die', true, 'string')
|
||||
@ -602,7 +621,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]Direction:[/color] ' .. entity.direction .. ' (' .. directions[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'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user