mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 12:11:33 -06:00
Factorio: add Progressive Option
This commit is contained in:
@@ -219,25 +219,41 @@ end)
|
||||
|
||||
|
||||
commands.add_command("ap-get-technology", "Grant a technology, used by the Archipelago Client.", function(call)
|
||||
if global.index_sync == nil then
|
||||
global.index_sync = {}
|
||||
end
|
||||
local tech
|
||||
local force = game.forces["player"]
|
||||
chunks = split(call.parameter, "\t")
|
||||
local tech_name = chunks[1]
|
||||
local index = chunks[2]
|
||||
local source = chunks[3] or "Archipelago"
|
||||
local tech = force.technologies[tech_name]
|
||||
|
||||
if tech ~= nil then
|
||||
if global.index_sync == nil then
|
||||
global.index_sync = {}
|
||||
if progressive_technologies[tech_name] ~= nil then
|
||||
if global.index_sync[index] == nil then -- not yet received prog item
|
||||
global.index_sync[index] = tech_name
|
||||
local tech_stack = progressive_technologies[tech_name]
|
||||
for _, tech_name in ipairs(tech_stack) do
|
||||
tech = force.technologies[tech_name]
|
||||
if tech.researched ~= true then
|
||||
game.print({"", "Received [technology=" .. tech.name .. "] from ", source})
|
||||
game.play_sound({path="utility/research_completed"})
|
||||
tech.researched = true
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
if global.index_sync[index] ~= nil and global.index_sync[index] ~= tech then
|
||||
game.print("Warning: Desync Detected. Duplicate/Missing items may occur.")
|
||||
end
|
||||
global.index_sync[index] = tech
|
||||
if tech.researched ~= true then
|
||||
game.print({"", "Received [technology=" .. tech.name .. "] from ", source})
|
||||
game.play_sound({path="utility/research_completed"})
|
||||
tech.researched = true
|
||||
elseif force.technologies[tech_name] ~= nil then
|
||||
tech = force.technologies[tech_name]
|
||||
if tech ~= nil then
|
||||
if global.index_sync[index] ~= nil and global.index_sync[index] ~= tech then
|
||||
game.print("Warning: Desync Detected. Duplicate/Missing items may occur.")
|
||||
end
|
||||
global.index_sync[index] = tech
|
||||
if tech.researched ~= true then
|
||||
game.print({"", "Received [technology=" .. tech.name .. "] from ", source})
|
||||
game.play_sound({path="utility/research_completed"})
|
||||
tech.researched = true
|
||||
end
|
||||
end
|
||||
else
|
||||
game.print("Unknown Technology " .. tech_name)
|
||||
@@ -247,4 +263,7 @@ end)
|
||||
|
||||
commands.add_command("ap-rcon-info", "Used by the Archipelago client to get information", function(call)
|
||||
rcon.print(game.table_to_json({["slot_name"] = SLOT_NAME, ["seed_name"] = SEED_NAME}))
|
||||
end)
|
||||
end)
|
||||
|
||||
-- data
|
||||
progressive_technologies = {{ dict_to_lua(progressive_technology_table) }}
|
@@ -72,9 +72,11 @@ prep_copy(new_tree_copy, original_tech)
|
||||
{% if tech_cost_scale != 1 %}
|
||||
new_tree_copy.unit.count = math.max(1, math.floor(new_tree_copy.unit.count * {{ tech_cost_scale }}))
|
||||
{% endif %}
|
||||
{%- if item_name in tech_table and tech_tree_information == 2 or original_tech_name in static_nodes -%}
|
||||
{%- if (tech_tree_information == 2 or original_tech_name in static_nodes) and item_name in base_tech_table -%}
|
||||
{#- copy Factorio Technology Icon -#}
|
||||
copy_factorio_icon(new_tree_copy, "{{ item_name }}")
|
||||
{%- elif (tech_tree_information == 2 or original_tech_name in static_nodes) and item_name in progressive_technology_table -%}
|
||||
copy_factorio_icon(new_tree_copy, "{{ progressive_technology_table[item_name][0] }}")
|
||||
{%- else -%}
|
||||
{#- use default AP icon if no Factorio graphics exist -#}
|
||||
{% if advancement or not tech_tree_information %}set_ap_icon(new_tree_copy){% else %}set_ap_unimportant_icon(new_tree_copy){% endif %}
|
||||
|
@@ -5,10 +5,18 @@
|
||||
{% endfor -%}
|
||||
}
|
||||
{%- endmacro %}
|
||||
{% macro list_to_lua(list) -%}
|
||||
{
|
||||
{%- for key in list -%}
|
||||
{{ variable_to_lua(key) }}{% if not loop.last %},{% endif %}
|
||||
{% endfor -%}
|
||||
}
|
||||
{%- endmacro %}
|
||||
{%- macro variable_to_lua(value) %}
|
||||
{%- if value is mapping -%}{{ dict_to_lua(value) }}
|
||||
{%- elif value is boolean -%}{{ value | string | lower }}
|
||||
{%- elif value is string -%} "{{ value | safe }}"
|
||||
{%- elif value is string -%}"{{ value | safe }}"
|
||||
{%- elif value is iterable -%}{{ list_to_lua(value) }}
|
||||
{%- else -%} {{ value | safe }}
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
Reference in New Issue
Block a user