Page 1 of 1

pickup_position and drop_position for ghost entities

Posted: Fri Dec 30, 2016 6:25 am
by Mylon
While trying to create a mod to search and auto-upgrade inserters, I ran into an error with ghosts causing errors. When I try to copy an inserter's pickup/dropoff locations onto a ghost, I get an error.

Here is the specific code:

Code: Select all

roboport.surface.create_entity{name="entity-ghost", position=inserter.position, inner_name="fast-inserter",  direction = inserter.direction, force=roboport.force, pickup_position=inserter.pickup_position, drop_position=inserter.drop_position}
Here is the error it produces: "Vector is not a safe distance from the tile edge".

This error occurs whether I use pickup_position or drop_position or both, though I included both in my code snippet for brevity.

I wanted to do this to support a popular mod, but this error happens even without that mod.

Re: pickup_position and drop_position for ghost entities

Posted: Fri Dec 30, 2016 8:35 pm
by Rseding91
pickup_position and drop_position when used in the context you're giving are meant to be vectors and you're giving them absolute positions. You need to adjust the position you get from the live inserter to account for the inserters position and then pass that.

Simply put: subtract the inserter position from the pickup/drop position you get before passing it to create_entity and it will work.

Re: pickup_position and drop_position for ghost entities

Posted: Fri Jul 28, 2017 1:47 am
by d3x0r
84.367 Error MainLoop.cpp:945: Exception at tick 273611: Error while running event upgrade-planner2::on_player_alt_selected_area (ID 50)
Vector is not a safe distance from the tile edge.

Code: Select all

  player.cursor_stack.set_stack{name = "blueprint", count = 1}
  player.cursor_stack.create_blueprint{surface = surface, force = f,area = a}
  local old_blueprint = player.cursor_stack.get_blueprint_entities()
  player.cursor_stack.set_blueprint_entities(old_blueprint) -- this is the line that gets the exception
Making a blueprint of exsiting inserter with an adjusted pickup/dropoff position fails, just putting the same entities back into the blueprint.
All I would be doing otherwise is changing the name.

--
Realized that the same problem should exist when upgrading a blueprint with an adjusted inserter position...
same problem happens getting the entties from an existing blueprint and putting those items back into the same blueprint after changing the name.

--
Edit2: heard news that this is fixed in 0.15.32