copy_settinsg is supposed to copy the settings from the entity given in the first argument to the entity it is called on.
it does so when by_player is not given as a second arg, however does the opposite when it is.
Reproduce
run this test codeCode: Select all
/c
--[[config]]
local player = game.player
local surface = player.surface
local test_assembling_machine_name = "assembling-machine-1"
local test_recipe_name_1 = "transport-belt"
local test_recipe_name_2 = "fast-transport-belt"
--[[setup]]
local source_entity_1 = surface.create_entity{name = test_assembling_machine_name, position = {0, 0}}
local destination_entity_1 = surface.create_entity{name = test_assembling_machine_name, position = {3, 0}}
local source_entity_2 = surface.create_entity{name = test_assembling_machine_name, position = {0, 4}}
local destination_entity_2 = surface.create_entity{name = test_assembling_machine_name, position = {3, 4}}
source_entity_1.set_recipe(test_recipe_name_1)
source_entity_2.set_recipe(test_recipe_name_1)
destination_entity_1.set_recipe(test_recipe_name_2)
destination_entity_2.set_recipe(test_recipe_name_2)
--[[action]]
destination_entity_1.copy_settings(source_entity_1)
destination_entity_2.copy_settings(source_entity_2, player)
--[[test]]
local success = true
if source_entity_1.get_recipe().name ~= test_recipe_name_1
or destination_entity_1.get_recipe().name ~= test_recipe_name_1
then
game.print("entity.copy_settings WITHOUT by_player copied incorrectly")
success = false
end
if source_entity_2.get_recipe().name ~= test_recipe_name_1
or destination_entity_2.get_recipe().name ~= test_recipe_name_1
then
game.print("entity.copy_settings WITH by_player copied incorrectly")
success = false
end
if success then
game.print("entity.copy_settings copied correctly")
end
--[[cleanup]]
source_entity_1.destroy()
source_entity_2.destroy()
destination_entity_1.destroy()
destination_entity_2.destroy()
Code: Select all
/c
script.on_event(defines.events.on_entity_settings_pasted, function(event)
if event.source.position.x > event.destination.position.x then
game.print("on_entity_settings_pasted received source and destination INcorrectly")
else
game.print("on_entity_settings_pasted received source and destination correctly")
end
end)