Skip to content

Instantly share code, notes, and snippets.

@Drac346
Last active October 1, 2017 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Drac346/ca87492c7f4ca5310da7d04bd4f2a5ca to your computer and use it in GitHub Desktop.
Save Drac346/ca87492c7f4ca5310da7d04bd4f2a5ca to your computer and use it in GitHub Desktop.
Random Factorio 0.15 LUA Scripts for Custom Servers (these will disable achievements)
#walkthought: https://www.accessdenied.wtf/single-post/2017/09/24/Factorio-15-Server-Customizations-with-LUA-Commands
#Set game to peaceful mode (global setting)
/c game.player.surface.peaceful_mode=true
#In the next section, replace "player_name_[1,2,3]" with whatever name makes sense to you
#create player factions (this is for 4 players, 3 named and the default [player] faction)
/c game.create_force('f_player_name_1')
/c game.create_force('f_player_name_2')
/c game.create_force('f_player_name_3')
#set factions to peaceful (for more PvE setups where each faction has independent research trees instead of shared)
/c game.forces['f_player_name_1'].set_cease_fire('f_player_name_2', true);
/c game.forces['f_player_name_1'].set_cease_fire('f_player_name_3', true);
/c game.forces['f_player_name_1'].set_cease_fire('player', true);
#set factions to peaceful (for more PvE setups where each faction has independent research trees instead of shared)
/c game.forces['f_player_name_2'].set_cease_fire('f_player_name_1', true);
/c game.forces['f_player_name_2'].set_cease_fire('f_player_name_3', true);
/c game.forces['f_player_name_2'].set_cease_fire('player', true);
#set factions to peaceful (for more PvE setups where each faction has independent research trees instead of shared)
/c game.forces['f_player_name_3'].set_cease_fire('f_player_name_1', true);
/c game.forces['f_player_name_3'].set_cease_fire('f_player_name_2', true);
/c game.forces['f_player_name_3'].set_cease_fire('player', true);
#set factions to peaceful (for more PvE setups where each faction has independent research trees instead of shared)
/c game.forces['player'].set_cease_fire('f_player_name_1', true);
/c game.forces['player'].set_cease_fire('f_player_name_2', true);
/c game.forces['player'].set_cease_fire('f_player_name_3', true);
#set players to peaceful (for more PvE setups where each faction has independent research trees instead of shared)
/c game.players['player_name_1'].force=game.forces['f_player_name_1']
/c game.players['player_name_1'].force=game.forces['player']
/c game.players['player_name_1'].force=game.forces['f_default']
#set players to peaceful (for more PvE setups where each faction has independent research trees instead of shared)
/c game.players['player_name_2'].force = game.forces['f_player_name_3']
/c game.players['player_name_3'].force = game.forces['f_player_name_2']
########################################
#Something to keep in mind: (player = me, players[] = array of people, players['player_name'] also works)
########################################
#Print Name
/c game.print(game.player.name)
/c game.print(game.players[2].name)
/c game.print(game.players['player_name'].name)
#ListAllPlayers (their Player# is based on the order listed, 1 is first)
/c for _, p in pairs(game.players) do game.player.print(p.name); end
#Get-Coordinates (first line is SELF, second line is someone from the PLAYERS[#] Array
/c game.print({"", "(", game.player.position.x, ", ", game.player.position.y, ")"})
/c game.print({"", "(", game.players[2].position.x, ", ", game.players[2].position.y, ")"})
#Set-Coordinates
/c game.player.teleport({0,0})
/c game.player.teleport({game.players[2].position.x,game.players[2].position.y})
/c local person = game.players['player_name_1']; person.teleport({0,1500},person.surface)
#Get-Map (this reveals the map)
/c local radius = 100; game.player.force.chart(game.player.surface, {{game.player.position.x - radius, game.player.position.y - radius}, {game.player.position.x + radius, game.player.position.y + radius}})
#only refresh revealed sections
/c game.player.force.rechart()
#hides map and makes discovery start over (does not unload chunks from the server)
/c game.player.force.clear_chart(game.player.surface)
/c game.players['player_name_1'].force.clear_chart(game.players['player_name_1'].surface)
#Set-PeacefulMode-Player (I think this is per player, need to kill all spawned enemies to refresh values)
/c game.player.surface.peaceful_mode=true
/c game.players[2].surface.peaceful_mode=true
#Set-BiterExpansion (global)
/c game.map_settings.enemy_expansion.enabled = false
#New-Resources (stone, iron-ore,copper-ore, coal)
/c for y=-15,15 do for x=-7,7 do game.player.surface.create_entity({name="copper-ore", amount=5000, position={game.player.position.x+x, game.player.position.y+y}}) end end
/c for y=0,4 do for x=0,4 do game.player.surface.create_entity({name="crude-oil", amount=5000, position={game.player.position.x+x*7-7, game.player.position.y+y*7-7}}) end end
#Remove-ShownEnemies (change radius, 100 is a little larger than a full zoomed out game view (not map view))
/c local radius = 200; local person = game.players[2]; for key, entity in pairs(person.surface.find_entities_filtered({area={{person.position.x - radius, person.position.y - radius}, {person.position.x + radius, person.position.y + radius}}, force= "enemy"})) do entity.destroy() end
#use after changing peacefulmode
/c game.forces["enemy"].kill_all_units()
#Set-SpawnPoint (this might actually be global and not per person, but it accepts a 'person' command)
/c local person = game.players[2]; person.force.set_spawn_position({person.position.x,person.position.y},person.surface)
#Set-AdminMode (selected = mouseover)
/c game.player.character = nil
/c game.player.character = game.player.selected
#New-BaseTemplate (random examples of the above code)
#Note 1:reference the examples above if you don't know what the commands are doing
#Note 2: create admin faction and expore the map to find good starting locations.
/c local person = game.players['player_name']; person.surface.peaceful_mode=true
/c game.forces["enemy"].kill_all_units()
/c local person = game.players['player_name_1']; person.teleport({262,1887},person.surface)
/c local person = game.players['player_name_2']; person.teleport({-23,-1948},person.surface)
/c local person = game.players['player_name_3']; person.teleport({230,3913},person.surface)
#repeat the below with updated player names as necessary
/c local radius = 600; local person = game.players['player_name_1']; for key, entity in pairs(person.surface.find_entities_filtered({area={{person.position.x - radius, person.position.y - radius}, {person.position.x + radius, person.position.y + radius}}, force= "enemy"})) do entity.destroy() end
/c local radius = 100; local person = game.players['player_name_1']; person.force.chart(person.surface, {{person.position.x - radius, person.position.y - radius}, {person.position.x + radius, person.position.y + radius}})
/c local person = game.players['player_name_1']; person.force.set_spawn_position({person.position.x,person.position.y},person.surface)
/c local person = game.players['player_name_1'];person.force.clear_chart(person.surface)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment