mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 12:11:33 -06:00
Factorio integration
This commit is contained in:
22
data/factorio/mod/LICENSE.md
Normal file
22
data/factorio/mod/LICENSE.md
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2021 Berserker55
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
108
data/factorio/mod/control.lua
Normal file
108
data/factorio/mod/control.lua
Normal file
@@ -0,0 +1,108 @@
|
||||
-- for testing
|
||||
script.on_event(defines.events.on_tick, function(event)
|
||||
if event.tick%600 == 0 then
|
||||
dumpTech()
|
||||
end
|
||||
end)
|
||||
|
||||
-- hook into researches done
|
||||
script.on_event(defines.events.on_research_finished, function(event)
|
||||
game.print("Research done")
|
||||
dumpTech()
|
||||
end)
|
||||
|
||||
function dumpTech()
|
||||
|
||||
local force = game.forces["player"]
|
||||
local data_collection = {}
|
||||
for tech_name, tech in pairs(force.technologies) do
|
||||
if tech.researched and string.find(tech_name, "ap-") == 1 then
|
||||
data_collection[tech_name] = tech.researched
|
||||
end
|
||||
end
|
||||
game.write_file("research_done.json", game.table_to_json(data_collection), false)
|
||||
-- game.write_file("research_done.json", game.table_to_json(data_collection), false, 0)
|
||||
-- game.print("Sent progress to Archipelago.")
|
||||
end
|
||||
|
||||
function dumpGameInfo()
|
||||
-- dump Game Information that the Archipelago Randomizer needs.
|
||||
local data_collection = {}
|
||||
local force = game.forces["player"]
|
||||
for tech_name, tech in pairs(force.technologies) do
|
||||
if tech.enabled then
|
||||
local tech_data = {}
|
||||
local unlocks = {}
|
||||
tech_data["unlocks"] = unlocks
|
||||
local requires = {}
|
||||
tech_data["requires"] = requires
|
||||
local ingredients = {}
|
||||
tech_data["ingredients"] = ingredients
|
||||
for tech_requirement, _ in pairs(tech.prerequisites) do
|
||||
table.insert(requires, tech_requirement)
|
||||
end
|
||||
for _, modifier in pairs(tech.effects) do
|
||||
if modifier.type == "unlock-recipe" then
|
||||
table.insert(unlocks, modifier.recipe)
|
||||
end
|
||||
end
|
||||
for _, ingredient in pairs(tech.research_unit_ingredients) do
|
||||
table.insert(ingredients, ingredient.name)
|
||||
end
|
||||
data_collection[tech_name] = tech_data
|
||||
|
||||
end
|
||||
game.write_file("techs.json", game.table_to_json(data_collection), false)
|
||||
game.print("Exported Tech Data")
|
||||
end
|
||||
data_collection = {}
|
||||
for recipe_name, recipe in pairs(force.recipes) do
|
||||
local recipe_data = {}
|
||||
recipe_data["ingredients"] = {}
|
||||
recipe_data["products"] = {}
|
||||
recipe_data["category"] = recipe.category
|
||||
for _, ingredient in pairs(recipe.ingredients) do
|
||||
table.insert(recipe_data["ingredients"], ingredient.name)
|
||||
end
|
||||
for _, product in pairs(recipe.products) do
|
||||
table.insert(recipe_data["products"], product.name)
|
||||
end
|
||||
data_collection[recipe_name] = recipe_data
|
||||
end
|
||||
game.write_file("recipes.json", game.table_to_json(data_collection), false)
|
||||
game.print("Exported Recipe Data")
|
||||
-- data.raw can't be accessed from control.lua, need to find a better method
|
||||
-- data_collection = {}
|
||||
-- for machine_name, machine in pairs(data.raw["assembling_machine"]) do
|
||||
-- local machine_data = {}
|
||||
-- machine_data["categories"] = table.deepcopy(machine.crafting_categories)
|
||||
-- data_collection[machine.name] = machine_data
|
||||
-- end
|
||||
-- game.write_file("machines.json", game.table_to_json(data_collection), false)
|
||||
-- game.print("Exported Machine Data")
|
||||
end
|
||||
|
||||
-- add / commands
|
||||
|
||||
commands.add_command("ap-get-info-dump", "Dump Game Info, used by Archipelago.", function(call)
|
||||
dumpGameInfo()
|
||||
end)
|
||||
|
||||
commands.add_command("ap-sync", "Run manual Research Sync with Archipelago.", function(call)
|
||||
dumpTech()
|
||||
end)
|
||||
|
||||
commands.add_command("ap-get-technology", "Grant a technology, used by the Archipelago Client.", function(call)
|
||||
local force = game.forces["player"]
|
||||
local tech_name = call.parameter
|
||||
local tech = force.technologies[tech_name]
|
||||
if tech ~= nil then
|
||||
if tech.researched ~= true then
|
||||
tech.researched = true
|
||||
game.print({"", "Received ", tech.localised_name, " from Archipelago"})
|
||||
game.play_sound({path="utility/research_completed"})
|
||||
end
|
||||
else
|
||||
game.print("Unknown Technology " .. tech_name)
|
||||
end
|
||||
end)
|
0
data/factorio/mod/data.lua
Normal file
0
data/factorio/mod/data.lua
Normal file
BIN
data/factorio/mod/graphics/icons/ap.png
Normal file
BIN
data/factorio/mod/graphics/icons/ap.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 264 KiB |
9
data/factorio/mod/info.json
Normal file
9
data/factorio/mod/info.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "archipelago-client",
|
||||
"version": "0.0.1",
|
||||
"title": "Archipelago",
|
||||
"author": "Berserker",
|
||||
"homepage": "https://archipelago.gg",
|
||||
"description": "Integration client for the Archipelago Randomizer",
|
||||
"factorio_version": "1.1"
|
||||
}
|
34
data/factorio/mod_template/data-final-fixes.lua
Normal file
34
data/factorio/mod_template/data-final-fixes.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
-- this file gets written automatically by the Archipelago Randomizer and is in its raw form a Jinja2 Template
|
||||
local technologies = data.raw["technology"]
|
||||
local original_tech
|
||||
local new_tree_copy
|
||||
local template_tech = table.deepcopy(technologies["automation"])
|
||||
{#- ensure the copy unlocks nothing #}
|
||||
template_tech.unlocks = {}
|
||||
template_tech.upgrade = false
|
||||
template_tech.effects = {}
|
||||
{# each randomized tech gets set to be invisible, with new nodes added that trigger those #}
|
||||
{%- for original_tech_name, item_name, receiving_player in locations %}
|
||||
original_tech = technologies["{{original_tech_name}}"]
|
||||
{#- the tech researched by the local player #}
|
||||
new_tree_copy = table.deepcopy(template_tech)
|
||||
new_tree_copy.name = "ap-{{ tech_table[original_tech_name] }}-"{# use AP ID #}
|
||||
{#- hide and disable original tech; which will be shown, unlocked and enabled by AP Client #}
|
||||
original_tech.enabled = false
|
||||
{#- copy original tech costs #}
|
||||
new_tree_copy.unit = table.deepcopy(original_tech.unit)
|
||||
{% if item_name in tech_table %}
|
||||
{#- copy Factorio Technology Icon #}
|
||||
new_tree_copy.icon = table.deepcopy(technologies["{{ item_name }}"].icon)
|
||||
new_tree_copy.icons = table.deepcopy(technologies["{{ item_name }}"].icons)
|
||||
new_tree_copy.icon_size = table.deepcopy(technologies["{{ item_name }}"].icon_size)
|
||||
{% else %}
|
||||
{#- use default AP icon if no Factorio graphics exist #}
|
||||
new_tree_copy.icon = "__{{ mod_name }}__/graphics/icons/ap.png"
|
||||
new_tree_copy.icons = nil
|
||||
new_tree_copy.icon_size = 512
|
||||
{% endif %}
|
||||
{#- add new technology to game #}
|
||||
data:extend{new_tree_copy}
|
||||
|
||||
{% endfor %}
|
8
data/factorio/mod_template/locale/en/locale.cfg
Normal file
8
data/factorio/mod_template/locale/en/locale.cfg
Normal file
@@ -0,0 +1,8 @@
|
||||
[technology-name]
|
||||
{% for original_tech_name, item_name, receiving_player in locations %}
|
||||
ap-{{ tech_table[original_tech_name] }}-={{ player_names[receiving_player] }}'s {{ item_name }}
|
||||
{% endfor %}
|
||||
[technology-description]
|
||||
{% for original_tech_name, item_name, receiving_player in locations %}
|
||||
"ap-{{ tech_table[original_tech_name] }}-=Researching this technology sends {{ item_name }} to {{ player_names[receiving_player] }}.
|
||||
{% endfor %}
|
1
data/factorio/recipes.json
Normal file
1
data/factorio/recipes.json
Normal file
File diff suppressed because one or more lines are too long
1
data/factorio/techs.json
Normal file
1
data/factorio/techs.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user