Prerequisites:
- To play over the internet the server has to open router port 34197 and check 'Use P2P communications' while starting the server.
- Default is co-op mode. To play PvP properly you have to first allow to use console commands to set it up, while starting the server.
- To open the console, by default, type: ~ (check your options->controls->game->'Toggle LUA-Console' to inspect and set the console key if needed)
Preparation:
Create two (or more) forces, give them any name you like, for example:
Code: Select all
/c game.create_force('Force_1')
/c game.create_force('Force_2')
Code: Select all
/c game.forces['Force_1'].set_cease_fire('Force_2', false)
/c game.forces['Force_2'].set_cease_fire('Force_1', false)
Code: Select all
/c local surface = game.local_player.surface
for c in surface.get_chunks() do
for key, entity in pairs(surface.find_entities_filtered({area={{c.x * 32, c.y * 32}, {c.x * 32 + 32, c.y * 32 + 32}}, force= "enemy"})) do
entity.destroy()
end
end
Code: Select all
/c game.local_player.force.chart(game.local_player.surface,{lefttop = {x = -1024, y = -1024}, rightbottom = {x = 1024, y = 1024}})
teleport({X,Y}) uses x as horizontal, left is negative values, right is positive values
and uses y as vertical, top is negative values, bottom is positive values
For example, topleft corner of the now visible map is (-1000,-1000)
Just estimate a good second position from the map: for example: -400, 200
Code: Select all
/c game.get_player('YOUR_PLAYER_NAME').teleport({-400, 200})
Code: Select all
/c game.forces['Force_2'].set_spawn_position({-400, 200}, game.get_surface(1))
Code: Select all
/c game.get_player('YOUR_PLAYER_NAME').color = {r=0.52, g=0.61, b=0.15, a=0.8}
Do the command to clear enemy's from the second force location once more, to clear away an even patch of land for expansion for both players.
SAVE this game
When your friend connects:
Note: When connecting to the server, you only need to give the IP number, no port number is needed
Do these commands:
Set his color:
Code: Select all
/c game.get_player('FRIENDS_NAME').color = {r=0.22, g=0.99, b=0.99, a=0.8}
Code: Select all
/c game.get_player('FRIENDS_NAME').force.chart(game.get_player('FRIENDS_NAME').surface,{lefttop = {x =-1024, y = -1024}, rightbottom = {x = 1024, y = 1024}})
Code: Select all
/c game.get_player('FRIENDS_NAME').force = game.forces['Force_1']
/c game.get_player('YOUR_PLAYER_NAME').force = game.forces['Force_2']
SAVE the game, and to prevent cheating: quit, start again and load, but this time without allowing commands
Let your friend reconnect, and start playing PvP!