mickael9 / cut-and-paste

Quickly cut or copy an area and paste it where you want (single-use blueprints). External circuit connections are restored when possible.
MIT License
3 stars 2 forks source link

attempt to perform arithmetic on field 'x' #9

Closed alexaulbach closed 7 years ago

alexaulbach commented 7 years ago

I just pasted a simple pastic factory:

Error while running event cut-and-paste::on_tick (ID 0) cut-and-paste/control.lua:202: attempt to perform arithmetic on field 'x' (a nil value)

alexaulbach commented 7 years ago

As far as I can currently say, this happens in the tick() function: placeholders center_pos and top_pos are empty tables.

screen shot 2017-07-09 at 09 40 44

The "XXXXXX" is some debug output I made into the sub_points() method. The same with "match pos src" somwhere (before the other call)

alexaulbach commented 7 years ago

Some more information: This bug "fixes itself", if you copy/paste first very small parts and then bigger and bigger parts of what you want to copy. Some missing initialization of selection?

mickael9 commented 7 years ago

I think the bug is caused because you're trying to place the selection over tile ghosts.

FYI, the placeholders are used to detect in which direction the blueprint was placed. Since the game doesn't expose that information, I had to use a hack where you're actually placing is just a set of two tiles. Their position is recorded but they're not actually built. After that, the real blueprint is placed using the detected direction and is used later to match source entities with the destination entities in order to support features such as wire reconnections and removal of colliding entities

This seems to be a bug in the game: placing a regular blueprint with tiles won't replace the "conflicting" tile ghosts (although they would be replaced if they were real tiles of the same type). I reported a bug here: https://forums.factorio.com/viewtopic.php?f=7&t=50793

If this doesn't get fixed, then I guess I'll have to find yet another hack (or just cancel the operation with an error message rather than crashing) :disappointed:

aulbach commented 7 years ago

ACK for the conflicting tile-ghosts: When I now think to it I placed the BP on tiles that where concrete-ghosts. And it suddenly worked after small tests, cause my personal bots did build the remaining concrete meanwhile.