Before you start doing anything, you have to know how to call Factorio in-game console, because it's only place where you will be doing all changes.
Warning, when you are using any Lua based commands, you'll possibly get some errors, even if you not messing with syntax. So, before changing anything, DO A BACKUP of you MAP. Some of changes you'll be doing are really difficult or even impossible to revert!!
To work with console commands, when you creating a Multiplayer server, you have to set "Alow commands" to "True". If you did this, or just playing\testing in single-player, press a "~" on your keyboard. From here you can write messages to other players, commands, or even parts of Lua script. You can check which commands are available for you by writing "/h" command in console, and pressing 'Enter' on you keyboard. Take a look on "/c" and it's description, because everything in this guide will be done with this command. The main goal of this command is allow you to execute parts of Lua scripts (most factorio mods wrote in Lua)
Because all the commands described in this guide, are actually small lua scripts, you have to write them in console, with '/c ' prefix, like this:
Code: Select all
/c game.player.print( game.player.force.name )
Before doing anything, let's gather some useful info.
To find out in which team you are currently in, do:
Code: Select all
game.player.print( game.player.force.name )
Code: Select all
for F in pairs(game.forces) do game.player.print(F) end
- 'player' -- default team for all new players who joins the game, including you.
- 'enemy' -- default team for aliens, their hives, bitters, spitters etc.
- 'neutral' -- empty team by default, but you can join it to build some infrastructure accessible for members of all teams, including currently not existing.
So let's prepare some teams for our players.
To create a Team with name 'Team1':
Code: Select all
game.create_force('Team1')
To remove team 'Team1', merge it with default team 'player':
Code: Select all
game.merge_forces('Team1', 'player')
To assign a player with name 'Player1' to the team 'Team1':
Code: Select all
game.players['Player1'].force=game.forces['Team1']
Code: Select all
game.players['Player1'].force=game.forces['player']
Code: Select all
game.forces['player'].set_cease_fire('Team1', true)
game.forces['Team1'].set_cease_fire('player', true)
In this section we well talk about how to transfer some existing buildings and technologies from one team to another.
Because the transfer mechanics based on region scan, you have to determinate rectangular region in which changes will be made. To do so open the debug console, by pressing 'F4' on your keyboard, switch to the 'allways' tab, and check 'show_detailed_info' checkbox. (I also recommend you to check 'show_tile_grid' to turn on map grid, which allow you more easily understand block and chunks of the map). After checking needed options, press 'F4' again. You'll see some new info at the top left corner of game window. Take a look at the first string 'Cursor'. From first pair of braces you can get the coordinates of your cursor on the map. So, imagine a rectangle, which will cover all buildings required to transfer to another team. Put the cursor on the top left and bottom right corners of that imaginary rectangle, and write down cursor's coordinates (for my example it will be -10 -10 and 10 10, to form 20x20 rectangle)
Now we can scan which entities (players, environment, buildings, machines) are exists in the designated region:
Code: Select all
BS = game.surfaces[1].find_entities({{-10, -10}, {10, 10}}) for BD in pairs( BS ) do game.player.print( BS[BD].name ) end
Code: Select all
BS = game.surfaces[1].find_entities({{-10, -10}, {10, 10}}) for BD in pairs( BS ) do BS[BD].force = game.forces['Team1'] end
Code: Select all
game.forces['player'].research_progress = 1
Code: Select all
TR = game.forces['player'].technologies for T in pairs( TR ) do if TR[T].researched then game.player.print(T) end end
Code: Select all
TR = game.forces['player'].technologies for T in pairs( TR ) do if TR[T].researched then game.forces['Team1'].technologies[T].researched=true end end
This command will allow you, as admin, to freely give player 'Player1' 10 iron plates:
Code: Select all
game.players['Player1'].insert({name="iron-plate", count=10})
This command will allow you spawn 'Assembly machine' building, tier 1, with presetted recipe (assemble 'iron-stick') and bound to your team:
Code: Select all
game.surfaces[1].create_entity{name = "assembling-machine-1", position = {15, 3}, force=game.forces.player, recipe = "iron-stick"}
With this command script you can create some flying text, which will be visible for several seconds to everyone who working near designated coordinates:
Code: Select all
game.surfaces[1].create_entity{name = "flying-text", position = {0, 0}, text="Fly_Text-1"}
That's all for now. If I discover some more, I will update this guide. So, please subscribe