pickup_position and drop_position for ghost entities

Things that already exist in the current mod API
Post Reply
User avatar
Mylon
Filter Inserter
Filter Inserter
Posts: 513
Joined: Sun Oct 23, 2016 11:42 pm
Contact:

pickup_position and drop_position for ghost entities

Post 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.

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

Re: pickup_position and drop_position for ghost entities

Post 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.
If you want to get ahold of me I'm almost always on Discord.

d3x0r
Filter Inserter
Filter Inserter
Posts: 316
Joined: Sun Jun 04, 2017 8:56 am
Contact:

Re: pickup_position and drop_position for ghost entities

Post 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

Post Reply

Return to “Already exists”