[0.18.18] Possible bug with resource creation
[0.18.18] Possible bug with resource creation
TL;DR
RSO can't spawn resource that base game spawns correctly due to what seems to be rounding of position.
I've added support for this mod:
https://mods.factorio.com/mod/geothermalgen
And all seems well until you actually try to use the resource spawned by RSO.
It turns out that this resources is unusable - goethermal generator ("mining building") can't be placed on it.
It seems to be caused by the way that resource was created by the game and I'm unable to affect it in any way.
When those resources are generated by game mousing over them with debug tooltip shows that their center is at position ending with .5 in both axes. It seems to work the same way with oil for example.
When RSO spawns this resource it ends up on coordinate that ends with .0 and then mining building can't be palced on it.
I checked coordinates I'm sending to create entity and it doesn't really matter what I do to them - even making sure they end up as .5 still spawns resource deposit with coordinates rounded to .0.
I tried to compare this to spawning of oil wells and with them it doesn't matter what is the fractional part of coordinates - they always end up on position ending with .5. For some reason geomthermal vents don't apply that logic when created from lua.
RSO can't spawn resource that base game spawns correctly due to what seems to be rounding of position.
I've added support for this mod:
https://mods.factorio.com/mod/geothermalgen
And all seems well until you actually try to use the resource spawned by RSO.
It turns out that this resources is unusable - goethermal generator ("mining building") can't be placed on it.
It seems to be caused by the way that resource was created by the game and I'm unable to affect it in any way.
When those resources are generated by game mousing over them with debug tooltip shows that their center is at position ending with .5 in both axes. It seems to work the same way with oil for example.
When RSO spawns this resource it ends up on coordinate that ends with .0 and then mining building can't be palced on it.
I checked coordinates I'm sending to create entity and it doesn't really matter what I do to them - even making sure they end up as .5 still spawns resource deposit with coordinates rounded to .0.
I tried to compare this to spawning of oil wells and with them it doesn't matter what is the fractional part of coordinates - they always end up on position ending with .5. For some reason geomthermal vents don't apply that logic when created from lua.
Re: [0.18.18] Possible bug with resource creation
This seems like a problem the mods will need to solve
The game will round resources, all entities, depending on their collision box size
So the resource size should be adjusted, or the flag "placeable-off-grid" added
The game will round resources, all entities, depending on their collision box size
So the resource size should be adjusted, or the flag "placeable-off-grid" added
Re: [0.18.18] Possible bug with resource creation
Map generator forces resources entities onto middle of a tile regardless of how the prototype is defined ...
Normal entity creation will use tile size of the entity (explicit or infered from collision box) to determine how the entity should be aligned to tile grid (or if entity should be aligned to tile grid at all)
I agree this inconsistency is inconvenient - do you have suggestions what to do about it? What comes to my mind is forcing tile size of all resource entities to odd dimensions so they are always aligned to center of a tile. Don't know if that would cause problems to anyone.
Normal entity creation will use tile size of the entity (explicit or infered from collision box) to determine how the entity should be aligned to tile grid (or if entity should be aligned to tile grid at all)
I agree this inconsistency is inconvenient - do you have suggestions what to do about it? What comes to my mind is forcing tile size of all resource entities to odd dimensions so they are always aligned to center of a tile. Don't know if that would cause problems to anyone.
Re: [0.18.18] Possible bug with resource creation
Maybe just a bool in the 'surface.create_entity' whether to do the rounding or not,posila wrote: ↑Sat Apr 18, 2020 4:26 pmI agree this inconsistency is inconvenient - do you have suggestions what to do about it? What comes to my mind is forcing tile size of all resource entities to odd dimensions so they are always aligned to center of a tile. Don't know if that would cause problems to anyone.
It was the behavior for a lot of versions for the surface create_entity not to round, and to create at the position specific by the script.
This was changed by kovarex for some reason, not that long ago
Re: [0.18.18] Possible bug with resource creation
After recent pile of shit related to belt and pipe connections, I am quite unwilling to go in that direction.
Re: [0.18.18] Possible bug with resource creation
You can still set them placeable off grid with prototype flags, I don't see it makes a difference there
Re: [0.18.18] Possible bug with resource creation
I'm not sure how making resource dimensions odd would help - resource that is spawned here has following parameters:posila wrote: ↑Sat Apr 18, 2020 4:26 pmMap generator forces resources entities onto middle of a tile regardless of how the prototype is defined ...
Normal entity creation will use tile size of the entity (explicit or infered from collision box) to determine how the entity should be aligned to tile grid (or if entity should be aligned to tile grid at all)
I agree this inconsistency is inconvenient - do you have suggestions what to do about it? What comes to my mind is forcing tile size of all resource entities to odd dimensions so they are always aligned to center of a tile. Don't know if that would cause problems to anyone.
Code: Select all
ter.collision_box = {{ -2.8, -2.8}, {2.8, 2.8}}
ter.selection_box = {{ -2.7, -2.7}, {2.7, 2.7}}
ter.drawing_box = {{ -2.7, -2.7}, {2.7, 2.7}}
I'm kind of lost in rest of the discussion.
Does that mean that I can't support this resource in RSO because I can't spawn it correctly in any way?
I can make RSO ignore this resource completely but thats a bit drastic.
I'm also not sure what do you mean about placable off the grid flag - can this be even added to resource? And even if it could wouldn't it be kind of strange to make mod that adds resource require changes to allow other mods to place that resource?
Would a flag for create_entity like resource = true to make it work like resource generator work?
Re: [0.18.18] Possible bug with resource creation
Should I put in modding interface request for create entity flag resource or is this NaB and no changes will be considered?
Re: [0.18.18] Possible bug with resource creation
I like APIs that do the right thing by default. But I have trouble figuring out what "right thing" should be in this case. Should the game force resource entity tile size to be 1x1, regadless of dimensions defined in prototype? Should create_entity place resource entities as map generator would place them? Maybe map generator should not have special rule for aligning to grid for resource entities.
For one moment I am leaning toward create_entity handling resource entities as map generator does (with an optional parameter to override this), but then ... if somebody defined the entity prototype the way they did, they probably wanted the entity not be aligned to middle of a tile, ... but then ... in this particular case, they clearly didn't know about grid alignment rules...
I really don't like just attaching more crap at our Frankenstein's moster of an API, becase it is so painful for everybody to change later, so whatever I do will probably stay that way forever.
But I also want to solve your problem. So ... people probably don't know how grid alignment works and they just define collision_box to whatever. Map generator always places resource entities to center of a tile. So by default I'd expect create_entity to do the same. If someone does know about grid alignment, and cares about their resource entity being aligned differently, that is the special case. Am I right in my thinking here?
Re: [0.18.18] Possible bug with resource creation
Making this automatic would be the best option. And I don't really think how anyone would want to have resource entity that wouldn't work with base game generator.posila wrote: ↑Tue May 05, 2020 9:08 amI like APIs that do the right thing by default. But I have trouble figuring out what "right thing" should be in this case. Should the game force resource entity tile size to be 1x1, regadless of dimensions defined in prototype? Should create_entity place resource entities as map generator would place them? Maybe map generator should not have special rule for aligning to grid for resource entities.
For one moment I am leaning toward create_entity handling resource entities as map generator does (with an optional parameter to override this), but then ... if somebody defined the entity prototype the way they did, they probably wanted the entity not be aligned to middle of a tile, ... but then ... in this particular case, they clearly didn't know about grid alignment rules...
I really don't like just attaching more crap at our Frankenstein's moster of an API, becase it is so painful for everybody to change later, so whatever I do will probably stay that way forever.
But I also want to solve your problem. So ... people probably don't know how grid alignment works and they just define collision_box to whatever. Map generator always places resource entities to center of a tile. So by default I'd expect create_entity to do the same. If someone does know about grid alignment, and cares about their resource entity being aligned differently, that is the special case. Am I right in my thinking here?
Re: [0.18.18] Possible bug with resource creation
For 0.18.23 I changed LuaSurface::create_entity so it places resource entities to center of a tile as map generator would. This can be overriden by optional snap_to_tile_center parameter.
Re: [0.18.18] Possible bug with resource creation
Thanks.
I'll restore the support for those resources in RSO once new version is out.
I'm understanding correctly that flag is true by default?