As the title says.
Okay, I'll keep it brief, but explain my issue.
Due to the transition away from having lots of different inserters (The complete item/recipe/entity combination) for different inserter configurations, to a GUI and hotkeys to change the configuration of an existing one, one of the issues that is coming up is that you can't configure them before they are placed.
So, I am working on that, but I have come up with an issue.
When the player places an entity, you can detect that and immediately change the configuration to match the intended layout, but there are a few issues.
If the player places a Ghost instead(by shift clicking), then trying to use pickup_position and drop_position comes up with an error stating that entity (ghost) doesn't have those values.
This is the issue I want to address. The ghost of an entity should inherit values unique to the entity type it is a ghost of, in the case of inserter, it's additional position values.
It would also allow you to configure inserter ghosts before the entity is placed. Speaking of, the values are clearly stored in the ghost, because the hand positions are copied if you use blueprints to copy a configured inserter.
Also on top of this issue, I see no method of changing the entity preview displayed while the item is in your hand, but I'm not sure if I should even ask for the ability to change that right now, so we'll leave that for another discussion.
Ghost insterters should have access to pickup/drop position
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Ghost insterters should have access to pickup/drop position
Pickup and dropoff where already 3/4ths working with ghosts.
The only thing that was bugged was reading the drop position off ghost inserters. Writing drop and pickup + reading pickup already work on ghosts.
As for the drop position read on ghost inserters that's fixed for 0.13.12 now.
The only thing that was bugged was reading the drop position off ghost inserters. Writing drop and pickup + reading pickup already work on ghosts.
As for the drop position read on ghost inserters that's fixed for 0.13.12 now.
If you want to get ahold of me I'm almost always on Discord.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Ghost insterters should have access to pickup/drop position
Ah, that makes sense.
I wrote the script first, that worked on inserters, noticed it didn't work on ghosts, then changed the trigger to include ghosts.
At this point, the ghost erred. (Erred is past tense for error, a grammatically correct alternative to saying "An error occurred")
the original function starts off by reading the existing hand positions of the entity, then adjusting them as necessary. This is done to use it as a reference point from the entity position to determine what direction the hand is reaching in, so when setting the reach to 1 or 2 tiles, I extend in the correct direction. On top of this, changing to tile offset position (near side, or far side of the belt) I simply round to a whole number of tiles, then add or subtract the offset.
At this point (since I didn't try reading/writing independently) I did not know I could write, but not read drop position. So this post helps with that information.
Although technically possible to calculate a new hand position based solely on direction, all new factors (Tile reach and near/far side drop offset) need to be known. The ability to change from the defaults requires research for that change to be available. In some cases, you might be wanting to change the drop offset without having the research done to change tile reach, in this instance, the inserters original position must be known, therefore the default pickup/drop positions of the inserter must be known, and can only be known by reading from the entity. Vica verca, you might be dealing with someone elses modded inserter which places on the near side of the belt, so you can't assume it's far side either when changing only the reach distance.
I did consider an alternate method of using LuaEntityPrototype to look up the hand positions of the base entity, by using the entities type and name given by the ghost.... but I can't do this because that method doesn't expose the hand positions for reading either.
An alternate alternate method would be to discover it is a ghost entity, create another entity that isn't a ghost in the same place, read it's values in, delete it, then apply to the ghost. This would most likely solve the problem for existing versions of the game before the update with the fix is released.
Either way, I thank you for making this change. It definitely makes life easier.
I wrote the script first, that worked on inserters, noticed it didn't work on ghosts, then changed the trigger to include ghosts.
At this point, the ghost erred. (Erred is past tense for error, a grammatically correct alternative to saying "An error occurred")
the original function starts off by reading the existing hand positions of the entity, then adjusting them as necessary. This is done to use it as a reference point from the entity position to determine what direction the hand is reaching in, so when setting the reach to 1 or 2 tiles, I extend in the correct direction. On top of this, changing to tile offset position (near side, or far side of the belt) I simply round to a whole number of tiles, then add or subtract the offset.
At this point (since I didn't try reading/writing independently) I did not know I could write, but not read drop position. So this post helps with that information.
Although technically possible to calculate a new hand position based solely on direction, all new factors (Tile reach and near/far side drop offset) need to be known. The ability to change from the defaults requires research for that change to be available. In some cases, you might be wanting to change the drop offset without having the research done to change tile reach, in this instance, the inserters original position must be known, therefore the default pickup/drop positions of the inserter must be known, and can only be known by reading from the entity. Vica verca, you might be dealing with someone elses modded inserter which places on the near side of the belt, so you can't assume it's far side either when changing only the reach distance.
I did consider an alternate method of using LuaEntityPrototype to look up the hand positions of the base entity, by using the entities type and name given by the ghost.... but I can't do this because that method doesn't expose the hand positions for reading either.
An alternate alternate method would be to discover it is a ghost entity, create another entity that isn't a ghost in the same place, read it's values in, delete it, then apply to the ghost. This would most likely solve the problem for existing versions of the game before the update with the fix is released.
Either way, I thank you for making this change. It definitely makes life easier.