0.14.21 - Not possible to disable hitbox on a locomotive

Place to post guides, observations, things related to modding that are not mods themselves.
User avatar
Sparen
Inserter
Inserter
Posts: 33
Joined: Thu Jun 30, 2016 1:25 am
Contact:

0.14.21 - Not possible to disable hitbox on a locomotive

Post by Sparen »

I'm new to developing Factorio mods and amidst what is basically zero documentation as to modding trains, I've come across an issue with bounding boxes. Apparently it's not possible to set

Code: Select all

collision_box = {{0, 0}, {0, 0}}
. This is being said by someone who has no idea what the coordinates mean, but I naturally assumed that setting them to 0 would disable the collision box.

If this is done, the following error appears:
Image

Now, this makes me assume that there is no way to disable collision boxes at all. Additionally, I do not know which fields are safe to delete (I've been working using the base mod and electric vehicles as my primary references), since there is seemingly no documentation that I am aware of to explain.

Anyways, if someone could inform me how to disable collision between a train and all entities, that would be very helpful. If someone could point me to full documentation for all fields in a train prototype/metatable?/object? that would also be helpful. Finally, I'm confused as to how inheritance works in Factorio modding - in data:extend() in entity.lua, when we add a nested object into the parameter table, does that object inherit all fields of the type by default (and can we therefore delete some and end up defaulting to the originals) or are we supposed to include all the fields that we'd like to have in the final object?

Thank you.

P.S. I've worked with Lua before, but I switched to Moonscript almost immediately afterwards, so I'm unfamiliar with Lua's Prototyping and Metatable system.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: 0.14.21 - Not possible to disable hitbox on a locomotive

Post by Nexela »

I haven't worked too much with trains but according to the error your connection points are too far from your bounding box

try setting these to 0 or nil and see what your results are.
connection_distance
joint_distance
User avatar
Sparen
Inserter
Inserter
Posts: 33
Joined: Thu Jun 30, 2016 1:25 am
Contact:

Re: 0.14.21 - Not possible to disable hitbox on a locomotive

Post by Sparen »

What exactly is the bounding box though? I'm aware of three separate boxes - the collision hitbox, the mine/select box, and the render area, but...
CmdrKeen
Long Handed Inserter
Long Handed Inserter
Posts: 98
Joined: Tue Sep 29, 2015 9:03 pm
Contact:

Re: 0.14.21 - Not possible to disable hitbox on a locomotive

Post by CmdrKeen »

try:

Code: Select all

collision_box = nil
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: 0.14.21 - Not possible to disable hitbox on a locomotive

Post by Nexela »

Sparen wrote:What exactly is the bounding box though? I'm aware of three separate boxes - the collision hitbox, the mine/select box, and the render area, but...
A bounding box is just a box formed from a top_left and bottom_right position

{{-0.5, -0.5}, {0.5, 0.5}}
Is the same as:
{top_left={x=-0.5, y=-0.5}, bottom_right={x=0.5, y=0.5}}

Both of those will create a bounding box that is 1 tile (32 pixels) high, 1 tile (32 pixes) wide.

A collision box is a bounding box that collides with anything on the layer it is placed and anything below that layer.
A selection box is a bounding box that "selects" the entity when you are hovering over it with your mouse inside the bounding box.

The pipe-joint is probably an offset looking for an edge of the collision box to attach too
posila
Factorio Staff
Factorio Staff
Posts: 5440
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: 0.14.21 - Not possible to disable hitbox on a locomotive

Post by posila »

Unfortunately there is no documentation for these things (at least not yet).
Locomotive cannot have empty collision box, because they are required in order to rails correctly handle the locomotive.

If you don't want locomotive to collide with anything add property

Code: Select all

collision_mask = {"not-colliding-with-itself"}
or

Code: Select all

collision_mask = {}
I am not sure which one is more correct.

What we call prototypes is not what Lua or other languages call prototypes. Factorio prototypes are just tables containing properties of individual game elements/entities. We could have as well used JSON or XML for defining prototypes.

There is no inheritance in Factorio prototypes. If you want "diesel-locomotive-mk2" you have to copy "diesel-locomotive" and change what you need, or to write your prototype from scratch. For example:

Code: Select all

local cannon_projectile2 = util.table.deepcopy(data.raw.projectile["cannon-projectile"])
cannon_projectile2.name = "test-decelerating-cannon-projectile"
cannon_projectile2.acceleration = -0.1
data.raw.projectile["test-decelerating-cannon-projectile"] = cannon_projectile2
data:extend() just sorts given tables into proper buckets in data.raw
User avatar
Sparen
Inserter
Inserter
Posts: 33
Joined: Thu Jun 30, 2016 1:25 am
Contact:

Re: 0.14.21 - Not possible to disable hitbox on a locomotive

Post by Sparen »

Thank you all very much for the clarifications.
Post Reply

Return to “Modding discussion”