Page 1 of 1

clone a force under a new name

Posted: Thu Jul 23, 2020 8:31 pm
by StormyStrife
I'd like to request a command that can clone a force and all it's properties and settings under a different name

by this i mean, make a perfect copy of a force, with all the same base starting recipes and technologies, but none of the newly unlocked stuff, and under a different name, namely want it to put into my mod so i and others can play it PvP-style, since there will be multiple forces, all with different tech trees, and recipes

I'd make it myself, but i'm really unsure how tbh

Re: clone a force under a new name

Posted: Thu Jul 23, 2020 9:16 pm
by darkfrei
https://lua-api.factorio.com/latest/Lua ... eate_force
https://lua-api.factorio.com/latest/LuaForce.html
https://lua-api.factorio.com/latest/Lua ... chnologies
game.player.force.technologies["steel-processing"].researched = true

https://lua-api.factorio.com/latest/Lua ... pe.enabled

(not tested)

Code: Select all

/c
local old_force = game.player.force
local new_force = game.create_force("new-force")

game.player.force = new_force

local old_technologies = old_force.technologies
local new_technologies = new_force.technologies

for tech_name, tech in pairs (old_technologies) do
	new_technologies[tech_name].researched = tech.researched
end