collisions

Place to get help with not working mods / modding interface.
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

collisions

Post by Dysoch »

i am trying to add something that i want to be able to place UNDER buildings and belts, but without being to able to place on top of each other!

how to do this?

i already tried with

Code: Select all

collision_box = {{-0.00001, -0.0}, {0.00001, 0.0}},
but sadly that doesnt work! (it does not allow to be build on top of each other, but it also wont build under other buildings xD)
some help would be appreciated
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
kovarex
Factorio Staff
Factorio Staff
Posts: 8207
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: collisions

Post by kovarex »

This is sorted out by the collision masks, but these are currently hardcoded for individual entities and not moddable.
The collision layers are now:
  • ground-tile
  • water-tile
  • resource-layer
  • floor-layer
  • item-layer
  • object-layer
  • player-layer
  • ghost-layer
Every object has it's set of layers (bit-mask) and two objects collide when they share at least one layer.
This enables us to set the logic, that for example, items + player + car can be on transport belt, but buildings can't be on transport belt, and player can walk on top of items and resource/ghost collide with nothing but itself (similar to the thing you need).

This is very performance delicate, so if we make it moddable, the total count of moddable layers would have to be limited, currently the collision mask is 1 byte, and all 8 bits are used, so we would have it to extend to 2 bytes, and let the rest 8 bytes to be used by mod-specified collision layers.

I'm afraid we have way too much work planned for 0.9 to make it now, but we might do it in the future.
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: collisions

Post by Dysoch »

ok good to know, ill just do without the collisions. this will make them placeable on each other, but can be placed under everything else.

mmmm, maybe i can add them to a glob? and let a check run when you build one that will check the location, and i there is 1 present, it will be auto deleted and placed in inventory.

that would work for now right?
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
SilverWarior
Filter Inserter
Filter Inserter
Posts: 559
Joined: Mon Mar 04, 2013 9:23 am
Contact:

Re: collisions

Post by SilverWarior »

Dysoch wrote:i am trying to add something that i want to be able to place UNDER buildings and belts, but without being to able to place on top of each other!
kovarex wrote:The collision layers are now:
  • ground-tile
  • water-tile
  • resource-layer
  • floor-layer
  • item-layer
  • object-layer
  • player-layer
  • ghost-layer
Every object has it's set of layers (bit-mask) and two objects collide when they share at least one layer.
If I understand this correctly Dysoch would then have to use resource colision layer to achieve what he wants. Right?
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: collisions

Post by FreeER »

SilverWarior wrote:If I understand this correctly Dysoch would then have to use resource colision layer to achieve what he wants. Right?
well if it was accessible through lua then it would work, but it's not. And from what's been said they'd rather give the modders more options (a second byte for the mask) rather than force them to use the layer's that currently exist. makes me wonder about possible (placement/collision) conflicts between mods though...perhaps some semi-logical names for those layers would be created rather than modders simply arbitrarily choosing one to use? Hm, makes me wonder exactly what the 'floor-layer' is used for though, since the rest seem fairly obvious.

edit:
Dysoch wrote:mmmm, maybe i can add them to a glob? and let a check run when you build one that will check the location, and i there is 1 present, it will be auto deleted and placed in inventory.
Or simply use findentities in onbuiltentity to check for any existing ones at the placed coords, not sure which is actually more efficient in the long run but I'd guess findentities since it would only run when placing them rather than saving a table every few minutes.
SilverWarior
Filter Inserter
Filter Inserter
Posts: 559
Joined: Mon Mar 04, 2013 9:23 am
Contact:

Re: collisions

Post by SilverWarior »

FreeER wrote:And from what's been said they'd rather give the modders more options (a second byte for the mask) rather than force them to use the layer's that currently exist.
I think this would only be needed if mod would require new specific layers (existing ones wouldn't fit) desired logic.
FreeER wrote:Hm, makes me wonder exactly what the 'floor-layer' is used for though, since the rest seem fairly obvious.
I'm not sure but I suspect that is used for conveyor belts (item/player to belt colision for making items move).
kovarex
Factorio Staff
Factorio Staff
Posts: 8207
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: collisions

Post by kovarex »

FreeER wrote:
SilverWarior wrote:Makes me wonder about possible (placement/collision) conflicts between mods though...perhaps some semi-logical names for those layers would be created rather than modders simply arbitrarily choosing one to use?
It would work same as with EntityID, EntityID is internally just 16-bit number and every prototype get assigned the id when you start a new map, this id is used in game to save, for fast indexing prototypes and other stuff, as well as to keep saves small.
(Ofcourse, it is not as simple, as the game needs to remove unused IDS when you remove mod, or assign ids to new prototypes when you load map with new mods, and some other stuff).

Some similar automatic technique would be used for the layers.
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: collisions

Post by FreeER »

kovarex wrote:Some similar automatic technique would be used for the layers.
Hm...I'm trying to think ahead to when there might be multiple mods using multiple layers at the same time (more than eight in total, but the assignment would have to place some in the same layers because of the 8 bit limit). If one was using a layer for foundation and another was using it for some type of strange quantum building teleporter (or some other building type thing that you wouldn't want colliding with regular entities for whatever reason) the modders probably wouldn't want the automatic assignment to place them in the same layers. That's probably the best example I can come up with off the top of my head. Now I've no idea how much of an issue this might be, which is why I brought it up.
MF-
Smart Inserter
Smart Inserter
Posts: 1235
Joined: Sun Feb 24, 2013 12:07 am
Contact:

Re: collisions

Post by MF- »

Hmmm....
An underground layer..

That might prevent me from "crossing" underground belts and pipes.
I have no idea whether I rely on that "weirdness" or not (And thus no idea whether I would like those unrealistic situations gone or not)
Post Reply

Return to “Modding help”