clone a force under a new name

This is the place to request new mods or give ideas about what could be done.
Post Reply
User avatar
StormyStrife
Manual Inserter
Manual Inserter
Posts: 4
Joined: Mon May 11, 2020 12:38 am
Contact:

clone a force under a new name

Post 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
I normally draw, so modding is out of my depth quite a bit. I'm super dense at learning programming and that's frustrating.

I made the dumbest factorio mod ever made: Memebots.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: clone a force under a new name

Post 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

Post Reply

Return to “Ideas and Requests For Mods”