[0.18.26] LuaEntity.copy_settings copies in the wrong direction when by_player is given

This subforum contains all the issues which we already resolved.
Post Reply
User avatar
jan1i3
Long Handed Inserter
Long Handed Inserter
Posts: 59
Joined: Sun Dec 09, 2018 1:36 pm
Contact:

[0.18.26] LuaEntity.copy_settings copies in the wrong direction when by_player is given

Post by jan1i3 »

The title says it all, but here's a link to the docs and further clarification just in case:

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 code :)

Code: 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()
you may also run this command before the other one, if you want to check that on_entity_settings_pasted is getting source and destintation correctly

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)
(this currently says it's incorrect because the entire function is inversed, i hope that makes sense)
Note
oh and i can see how this happened, i was a bit confused by the function name the first time i used it too, but both copy_settings and paste_settings would make sense, so this is just how it is :D
Also known as JanSharp. jan1i3 was/is my old name ;)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.18.26] LuaEntity.copy_settings copies in the wrong direction when by_player is given

Post by Rseding91 »

Thanks for the report. It's now fixed for the next release.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Resolved Problems and Bugs”