Factorio: add toggle to disable imported blueprints

This commit is contained in:
Fabian Dill
2021-06-19 01:00:21 +02:00
parent 644d62c915
commit f8fd8b3585
3 changed files with 52 additions and 61 deletions

View File

@@ -6,7 +6,16 @@ require "util"
FREE_SAMPLES = {{ free_samples }}
SLOT_NAME = "{{ slot_name }}"
SEED_NAME = "{{ seed_name }}"
--SUPPRESS_INVENTORY_EVENTS = false
{% if not imported_blueprints -%}
function set_permissions()
local group = game.permissions.get_group("Default")
group.set_allows_action(defines.input_action.open_blueprint_library_gui, false)
group.set_allows_action(defines.input_action.import_blueprint, false)
group.set_allows_action(defines.input_action.import_blueprint_string, false)
group.set_allows_action(defines.input_action.import_blueprints_filtered, false)
end
{%- endif %}
-- Initialize force data, either from it being created or already being part of the game when the mod was added.
function on_force_created(event)
@@ -63,7 +72,7 @@ function update_player(index)
local sent
--player.print(serpent.block(data['pending_samples']))
local stack = {}
--SUPPRESS_INVENTORY_EVENTS = true
for name, count in pairs(samples) do
stack.name = name
stack.count = count
@@ -87,16 +96,14 @@ function update_player(index)
samples[name] = nil -- Remove from the list
end
end
--SUPPRESS_INVENTORY_EVENTS = false
end
-- Update players upon them connecting, since updates while they're offline are suppressed.
script.on_event(defines.events.on_player_joined_game, function(event) update_player(event.player_index) end)
function update_player_event(event)
--if not SUPPRESS_INVENTORY_EVENTS then
update_player(event.player_index)
--end
end
script.on_event(defines.events.on_player_main_inventory_changed, update_player_event)
@@ -115,6 +122,7 @@ function add_samples(force, name, count)
end
script.on_init(function()
{% if not imported_blueprints %}set_permissions(){% endif %}
global.forcedata = {}
global.playerdata = {}
-- Fire dummy events for all currently existing forces.