User:Darkfrei/script: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
This creates 9 crude oil patches randomly without collisions:
This creates 9 crude oil patches randomly without collisions:


<syntaxhighlight lang="lua">
  /c local position = nil
  /c local position = nil
  for i=1,9 do
  for i=1,9 do
Line 9: Line 10:
   end
   end
  end
  end
</syntaxhighlight>


=== Respawn enemies ===
=== Respawn enemies ===
This creates one respawner every 32x32 tiles:
This creates one respawner every 32x32 tiles:


<syntaxhighlight lang="lua">
  /c local surface = game.player.surface
  /c local surface = game.player.surface
  for c in surface.get_chunks() do
  for c in surface.get_chunks() do
Line 20: Line 23:
   end
   end
  end
  end
 
</syntaxhighlight>


=== Print all mods with versions to the log file ===
=== Print all mods with versions to the log file ===
For data stage:
<syntaxhighlight lang="lua">
   local mod_list = {}
   local mod_list = {}
   for i, v in pairs (mods) do
   for i, v in pairs (mods) do
Line 28: Line 33:
   end
   end
   log ('mods: ' .. serpent.line (mod_list))
   log ('mods: ' .. serpent.line (mod_list))
</syntaxhighlight>
=== Print collison mask ===
<syntaxhighlight lang="lua">
/c game.print (game.player.selected.prototype.name .. ' ' .. serpent.line(game.player.selected.prototype.collision_mask))
</syntaxhighlight>

Latest revision as of 18:33, 12 May 2020

Add new oil patch

This creates 9 crude oil patches randomly without collisions:

 /c local position = nil
 for i=1,9 do
   position = game.player.surface.find_non_colliding_position("crude-oil", game.player.position, 0, i/2+1.5)
   if position then 
     game.player.surface.create_entity({name="crude-oil", amount=5000, position=position})
   end
 end

Respawn enemies

This creates one respawner every 32x32 tiles:

 /c local surface = game.player.surface
 for c in surface.get_chunks() do
   local position = surface.find_non_colliding_position("biter-spawner", {x=c.x*32+16, y=c.y*32+16}, 10, 3)
   if position and surface.is_chunk_generated(c) then
     surface.create_entity{name="biter-spawner", position=position}
   end
 end

Print all mods with versions to the log file

For data stage:

  local mod_list = {}
  for i, v in pairs (mods) do
    table.insert (mod_list, i .. '_' ..v )
  end
  log ('mods: ' .. serpent.line (mod_list))

Print collison mask

/c game.print (game.player.selected.prototype.name .. ' ' .. serpent.line(game.player.selected.prototype.collision_mask))