How do I set a spawn point in a pvp scenario

Solution 1:

Short of finding an existing PvP Scenario that suits your needs, you can start a new game and manually configure teams and their spawn points. I found, but have not personally tested this mod that appears to have spawn point settings and looks like an otherwise normal game.

DIY Approach

Create a game with your desired settings. Make sure that you set yourself as an admin (for now) and start the game.

Create the teams

First, you'll need to create the teams. Open the console with ~ and enter the following (N.B. all commands can be pasted in game):

/c game.create_force('name')

Replace name with the desired force name, such as 'Team Awesome' for example (the quotes are necessary). Repeat this process as needed for each desired force; you can press while in the console to reuse the last command.

Note: A "force" is the game's term for a team or faction.

Set spawn positions

Now that you have the forces created, you'll need to set their spawn points. To do so, use the following command:

/c game.forces['name'].set_spawn_position({x = #, y = #}, game.surfaces[1])

-- OR, to automatically use your current position
/c game.forces['name'].set_spawn_position(game.player.position, game.surfaces[1])

Replace the #s with the desired X and Y coordinates. A simple way to determine the coordinates of a specific spot is to Ctrl+Alt+Left Click somewhere on the map to create a map ping; the coordinates will then be displayed in the console.

Assign players to teams

To assign a player to a force, use the following command:

/c game.players['player_name'].force = game.forces['force_name']

To get a list of the current players:

/c for _, player in pairs(game.players) do game.print(player.name) end

Use one of these names in place of 'player_name' above.

To get a list of the current forces:

/c for name, _ in pairs(game.forces) do game.print(name) end

You should see the three default forces: player, enemy, and neutral, along with the forces you added earlier. Use one of these names in place of 'force_name'.

That's it! If you want, save and create a backup of the map, in case you need to start over, but don't want to set up the forces again.

References

  • https://wiki.factorio.com/Multiplayer#Forces
  • https://lua-api.factorio.com
  • LuaGameScript.create_force
  • LuaForce.set_spawn_position
  • LuaControl.position