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

@ -121,6 +121,8 @@ class Toggle(Option):
def get_option_name(self):
return bool(self.value)
class DefaultOnToggle(Toggle):
default = 1
class Choice(Option):
def __init__(self, value: int):
@ -292,56 +294,30 @@ alttp_options: typing.Dict[str, type(Option)] = {
"shop_item_slots": ShopItemSlots,
}
mapshuffle = Toggle
compassshuffle = Toggle
keyshuffle = Toggle
bigkeyshuffle = Toggle
hints = Toggle
RandomizeDreamers = Toggle
RandomizeSkills = Toggle
RandomizeCharms = Toggle
RandomizeKeys = Toggle
RandomizeGeoChests = Toggle
RandomizeMaskShards = Toggle
RandomizeVesselFragments = Toggle
RandomizeCharmNotches = Toggle
RandomizePaleOre = Toggle
RandomizeRancidEggs = Toggle
RandomizeRelics = Toggle
RandomizeMaps = Toggle
RandomizeStags = Toggle
RandomizeGrubs = Toggle
RandomizeWhisperingRoots = Toggle
RandomizeRocks = Toggle
RandomizeSoulTotems = Toggle
RandomizePalaceTotems = Toggle
RandomizeLoreTablets = Toggle
RandomizeLifebloodCocoons = Toggle
RandomizeFlames = Toggle
hollow_knight_randomize_options: typing.Dict[str, type(Option)] = {
"RandomizeDreamers": RandomizeDreamers,
"RandomizeSkills": RandomizeSkills,
"RandomizeCharms": RandomizeCharms,
"RandomizeKeys": RandomizeKeys,
"RandomizeGeoChests": RandomizeGeoChests,
"RandomizeMaskShards": RandomizeMaskShards,
"RandomizeVesselFragments": RandomizeVesselFragments,
"RandomizeCharmNotches": RandomizeCharmNotches,
"RandomizePaleOre": RandomizePaleOre,
"RandomizeRancidEggs": RandomizeRancidEggs,
"RandomizeRelics": RandomizeRelics,
"RandomizeMaps": RandomizeMaps,
"RandomizeStags": RandomizeStags,
"RandomizeGrubs": RandomizeGrubs,
"RandomizeWhisperingRoots": RandomizeWhisperingRoots,
"RandomizeRocks": RandomizeRocks,
"RandomizeSoulTotems": RandomizeSoulTotems,
"RandomizePalaceTotems": RandomizePalaceTotems,
"RandomizeLoreTablets": RandomizeLoreTablets,
"RandomizeLifebloodCocoons": RandomizeLifebloodCocoons,
"RandomizeFlames": RandomizeFlames
"RandomizeDreamers": DefaultOnToggle,
"RandomizeSkills": DefaultOnToggle,
"RandomizeCharms": DefaultOnToggle,
"RandomizeKeys": DefaultOnToggle,
"RandomizeGeoChests": Toggle,
"RandomizeMaskShards": DefaultOnToggle,
"RandomizeVesselFragments": DefaultOnToggle,
"RandomizeCharmNotches": Toggle,
"RandomizePaleOre": DefaultOnToggle,
"RandomizeRancidEggs": Toggle,
"RandomizeRelics": DefaultOnToggle,
"RandomizeMaps": Toggle,
"RandomizeStags": Toggle,
"RandomizeGrubs": Toggle,
"RandomizeWhisperingRoots": Toggle,
"RandomizeRocks": Toggle,
"RandomizeSoulTotems": Toggle,
"RandomizePalaceTotems": Toggle,
"RandomizeLoreTablets": Toggle,
"RandomizeLifebloodCocoons": Toggle,
"RandomizeFlames": Toggle
}
hollow_knight_skip_options: typing.Dict[str, type(Option)] = {
@ -428,13 +404,16 @@ class FactorioStartItems(OptionDict):
default = {"burner-mining-drill": 19, "stone-furnace": 19}
factorio_options: typing.Dict[str, type(Option)] = {"max_science_pack": MaxSciencePack,
"tech_tree_layout": TechTreeLayout,
"tech_cost": TechCost,
"free_samples": FreeSamples,
"visibility": Visibility,
"starting_items": FactorioStartItems,
"recipe_time": RecipeTime}
factorio_options: typing.Dict[str, type(Option)] = {
"max_science_pack": MaxSciencePack,
"tech_tree_layout": TechTreeLayout,
"tech_cost": TechCost,
"free_samples": FreeSamples,
"visibility": Visibility,
"starting_items": FactorioStartItems,
"recipe_time": RecipeTime,
"imported_blueprints": DefaultOnToggle,
}
class AdvancementGoal(Choice):
@ -469,7 +448,11 @@ option_sets = (
if __name__ == "__main__":
import argparse
mapshuffle = Toggle
compassshuffle = Toggle
keyshuffle = Toggle
bigkeyshuffle = Toggle
hints = Toggle
test = argparse.Namespace()
test.logic = Logic.from_text("no_logic")
test.mapshuffle = mapshuffle.from_text("ON")

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.

View File

@ -94,7 +94,7 @@ Factorio:
visibility:
none: 0
sending: 1
random_tech_ingredients:
imported_blueprints: # can be turned off to prevent access to blueprints created outside the current world
on: 1
off: 0
starting_items: