Skip to content

Commit

Permalink
Fix various bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerkiz committed Nov 10, 2024
1 parent 7d9c42b commit 724777a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
1 change: 1 addition & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ stds.factorio_control = {
other_fields = false,
read_only = false,
fields = {
'set_win_ending_info',
'disable_tutorial_triggers',
'auto_save',
'ban_player',
Expand Down
2 changes: 0 additions & 2 deletions maps/mountain_fortress_v3/entities.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ local change_force_for_drills_token =
function (event)
local entity = event.entity
if not entity or not entity.valid then return end
local tech = game.forces.player.technologies['uranium-processing'].researched
if not tech then return end
entity.force = 'bonus_drill'
end
)
Expand Down
21 changes: 3 additions & 18 deletions utils/antigrief.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,6 @@ local this = {
admin_button_validation = {}
}

local blacklisted_types = {
['transport-belt'] = true,
['wall'] = true,
['underground-belt'] = true,
['inserter'] = true,
['land-mine'] = true,
['gate'] = true,
['lamp'] = true,
['mining-drill'] = true,
['splitter'] = true
}

local ammo_names = {
['artillery-targeting-remote'] = true,
['poison-capsule'] = true,
Expand Down Expand Up @@ -391,7 +379,7 @@ local function on_player_used_capsule(event)
for i = 1, #entities do
local e = entities[i]
local entity_name = e.name
if entity_name ~= name and entity_name ~= 'entity-ghost' and not blacklisted_types[e.type] then
if entity_name ~= name and entity_name ~= 'entity-ghost' then
count = count + 1
end
end
Expand Down Expand Up @@ -440,7 +428,7 @@ local function on_entity_died(event)
local cause = event.cause
local name

if (cause and cause.name == 'character' and cause.player and cause.force.name == event.entity.force.name and not blacklisted_types[event.entity.type]) then
if (cause and cause.name == 'character' and cause.player and cause.force.name == event.entity.force.name) then
local player = cause.player
name = player.name

Expand Down Expand Up @@ -487,7 +475,7 @@ local function on_entity_died(event)
str = str .. 'surface:' .. event.entity.surface.index
increment(this.friendly_fire_history, str)
Server.log_antigrief_data('friendly_fire', str)
elseif not blacklisted_types[event.entity.type] and this.whitelist_types[event.entity.type] then
elseif this.whitelist_types[event.entity.type] then
if cause then
if cause.force.name ~= 'player' then
return
Expand Down Expand Up @@ -573,9 +561,6 @@ local function on_player_mined_entity(event)
if entity.force.name ~= player.force.name then
return
end
if blacklisted_types[event.entity.type] then
return
end
if not this.mining_history then
this.mining_history = {}
end
Expand Down
28 changes: 28 additions & 0 deletions utils/freeplay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ local Global = require 'utils.global'
local Event = require 'utils.event'
local BottomFrame = require 'utils.gui.bottom_frame'
local Task = require 'utils.task_token'
local handler = require("event_handler")

if script.active_mods["space-age"] then
handler.add_lib(require("space-finish-script"))
else
handler.add_lib(require("silo-script"))
end

local Public = {}

Expand Down Expand Up @@ -102,6 +109,25 @@ local chart_starting_area = function ()
force.chart(surface, { { origin.x - r, origin.y - r }, { origin.x + r, origin.y + r } })
end

local init_ending_info = function ()
local is_space_age = script.active_mods["space-age"]
local info =
{
image_path = is_space_age and "victory-space-age.png" or "victory.png",
title = { "gui-game-finished.victory" },
message = is_space_age and { "victory-message-space-age" } or { "victory-message" },
bullet_points =
{
{ "victory-bullet-point-1" },
{ "victory-bullet-point-2" },
{ "victory-bullet-point-3" },
{ "victory-bullet-point-4" }
},
final_message = { "victory-final-message" },
}
game.set_win_ending_info(info)
end

local on_player_joined_game = function (event)
if not this.clear_mod_gui_top then
return
Expand Down Expand Up @@ -310,6 +336,7 @@ Event.on_init(
this.crashed_ship_items = ship_items()
this.crashed_debris_items = debris_items()
this.crashed_ship_parts = this.crashed_ship_parts or ship_parts()
init_ending_info()
end
end
)
Expand All @@ -324,6 +351,7 @@ local on_configuration_changed = function ()
if not this.init_ran then
this.init_ran = #game.players > 0
end
init_ending_info()
end

Event.on_configuration_changed(on_configuration_changed)
Expand Down

0 comments on commit 724777a

Please sign in to comment.