[0.18.18] Possible bug with resource creation

This subforum contains all the issues which we already resolved.
orzelek
Smart Inserter
Smart Inserter
Posts: 3922
Joined: Fri Apr 03, 2015 10:20 am
Contact:

[0.18.18] Possible bug with resource creation

Post by orzelek »

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.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5243
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [0.18.18] Possible bug with resource creation

Post by Klonan »

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

posila
Factorio Staff
Factorio Staff
Posts: 5317
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [0.18.18] Possible bug with resource creation

Post by posila »

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.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5243
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [0.18.18] Possible bug with resource creation

Post by Klonan »

posila wrote:
Sat Apr 18, 2020 4:26 pm
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.
Maybe just a bool in the 'surface.create_entity' whether to do the rounding or not,

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

posila
Factorio Staff
Factorio Staff
Posts: 5317
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [0.18.18] Possible bug with resource creation

Post by posila »

After recent pile of shit related to belt and pipe connections, I am quite unwilling to go in that direction.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5243
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [0.18.18] Possible bug with resource creation

Post by Klonan »

posila wrote:
Sat Apr 18, 2020 5:49 pm
After recent pile of shit related to belt and pipe connections, I am quite unwilling to go in that direction.
You can still set them placeable off grid with prototype flags, I don't see it makes a difference there

orzelek
Smart Inserter
Smart Inserter
Posts: 3922
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: [0.18.18] Possible bug with resource creation

Post by orzelek »

posila wrote:
Sat Apr 18, 2020 4:26 pm
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.
I'm not sure how making resource dimensions odd would help - resource that is spawned here has following parameters:

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}}
Total size of resource would be 5.6 - how would this make resource center end up at rounded coordinates?

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?

orzelek
Smart Inserter
Smart Inserter
Posts: 3922
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: [0.18.18] Possible bug with resource creation

Post by orzelek »

Should I put in modding interface request for create entity flag resource or is this NaB and no changes will be considered?

posila
Factorio Staff
Factorio Staff
Posts: 5317
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [0.18.18] Possible bug with resource creation

Post by posila »

orzelek wrote:
Tue Apr 21, 2020 10:52 pm
Should I put in modding interface request for create entity flag resource or is this NaB and no changes will be considered?
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?

orzelek
Smart Inserter
Smart Inserter
Posts: 3922
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: [0.18.18] Possible bug with resource creation

Post by orzelek »

posila wrote:
Tue May 05, 2020 9:08 am
orzelek wrote:
Tue Apr 21, 2020 10:52 pm
Should I put in modding interface request for create entity flag resource or is this NaB and no changes will be considered?
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?
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
Factorio Staff
Factorio Staff
Posts: 5317
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [0.18.18] Possible bug with resource creation

Post by posila »

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.

orzelek
Smart Inserter
Smart Inserter
Posts: 3922
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: [0.18.18] Possible bug with resource creation

Post by orzelek »

posila wrote:
Wed May 06, 2020 6:14 am
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.
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?

posila
Factorio Staff
Factorio Staff
Posts: 5317
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [0.18.18] Possible bug with resource creation

Post by posila »

orzelek wrote:
Wed May 06, 2020 4:01 pm
I'm understanding correctly that flag is true by default?
Yes

Post Reply

Return to “Resolved Problems and Bugs”