I'm new to lua and got confused by the behavior of this small piece of code while toying with surfaces:
Code: Select all
  _G.script.on_event(defines.events.on_chunk_generated,function(e)
    game.print(e.surface.name);
    if (e.surface == surface) then
      for _,entity in pairs(surface.find_entities()) do
        game.print("Destroying " .. entity.name);
        entity.destroy();
      end
      game.print("Destruction done");
      for _,player1 in pairs(force.players) do
        game.print("Teleporting " .. player1.name);
        player1.teleport({x=0,y=0},surface);
      end
    end;
  end);
Code: Select all
nauvis
nauvis
my_test
Destroying tree-05
Destroying green-hairy-grass
...
Destruction done
Teleporting simn
Destroying player




