Making rotatable non-square containers

Place to get help with not working mods / modding interface.
sillyfly
Smart Inserter
Smart Inserter
Posts: 1101
Joined: Sun May 04, 2014 11:29 am
Contact:

Making rotatable non-square containers

Post by sillyfly »

Hello everyone!
It is the first time I am trying to make a mod for factorio. I know how to program (though I have never really written something in lua!), so this shouldn't be a problem, I hope :)

Anyway - I am trying to make a container which is not square, and can be rotated. i.e. - a 2x1 chest that can either be vertical (1x2) or horizontal (2x1).
Looking at https://forums.factorio.com/wiki/inde ... /Container it seems that containers may only have 1 non-directional picture / size. So am I correct to assume that what I am trying to do is not possible with the current capabilities? Or am I misunderstanding something?

Thanks!
User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: Making rotatable non-square containers

Post by L0771 »

Try with this, i'm not sure

Code: Select all

		picture =
		{
			  north =
			  {
				filename = "__mod__/graphics/entities/pic-north.png",
				frame_count = 1,
				line_length = 1,
				priority = "extra-high",
				width = 44,
				height = 81,
				shift = {0, 0}
			  },
			  east =
			  {
				filename = "__mod__/graphics/entities/pic-east.png",
				frame_count = 1,
				line_length = 1,
				priority = "extra-high",
				width = 81,
				height = 44,
				shift = {0, 0}
			  },
			  south =
			  {
				filename = "__mod__/graphics/entities/pic-south.png",
				frame_count = 1,
				line_length = 1,
				priority = "extra-high",
				width = 44,
				height = 81,
				shift = {0, 0}
			  },
			  west =
			  {
				filename = "__mod__/graphics/entities/pic-west.png",
				frame_count = 1,
				line_length = 1,
				priority = "extra-high",
				width = 81,
				height = 44,
				shift = {0, 0}
			  },
		},
mm... or this...

Code: Select all

    pictures =
    {
      {
        filename = "__base__/graphics/entity/fish/fish-1.png",
        priority = "extra-high",
        width = 22,
        height = 36
      },
      {
        filename = "__base__/graphics/entity/fish/fish-2.png",
        priority = "extra-high",
        width = 32,
        height = 32
      }
    },
Can use base entities for examples, like splitter, is a 2x1 entity rotable.
sillyfly
Smart Inserter
Smart Inserter
Posts: 1101
Joined: Sun May 04, 2014 11:29 am
Contact:

Re: Making rotatable non-square containers

Post by sillyfly »

I tried both actually. With the first I get an error "no such node (filename)", while for the second I get "no such node (picture)"

I guess the problem is that a "container" requires a "picture" node which must have a "filename" node (and not north/east etc.)
Damrus
Long Handed Inserter
Long Handed Inserter
Posts: 51
Joined: Sat Aug 23, 2014 12:41 pm
Contact:

Re: Making rotatable non-square containers

Post by Damrus »

O I was actually doing something similiar with 5x1 boxes.

I was going to do the same thing I saw someone do with the left and right inserters and the slipstream boxes, and maybe thats something for you too.

Basicly what they did was; that they made a base version (the horizontal box or none directional box), that you could build in to a diffrently aligned one.

When you place the diffrently aligned box it just stayes there but when you remove it again. You could get back the original box, so you always have a choice as to which box you drop.

Maybe that helps!
sillyfly
Smart Inserter
Smart Inserter
Posts: 1101
Joined: Sun May 04, 2014 11:29 am
Contact:

Re: Making rotatable non-square containers

Post by sillyfly »

Thank you Damrus. I was hoping it was possible to make something more elegant, as it is more convenient to have one item that you can rotate rather then having to craft a new item every time you want a different orientation (even if the crafting takes no additional resources).

Do you know if anyone requested such a feature to be added? Or could you provide a link to that other mod you mentioned?
sillyfly
Smart Inserter
Smart Inserter
Posts: 1101
Joined: Sun May 04, 2014 11:29 am
Contact:

Re: Making rotatable non-square containers

Post by sillyfly »

Ok, seeing as there is no answer and having not found an older such request, I will make a request in the modding interface request forum :)

Edit: Here is the thread, if you want to follow, discuss, or see the answer (once it is answered!) -
https://forums.factorio.com/forum/vie ... =28&t=7466
Rahjital
Filter Inserter
Filter Inserter
Posts: 435
Joined: Thu May 29, 2014 10:44 am
Contact:

Re: Making rotatable non-square containers

Post by Rahjital »

If you aren't afraid of a bit of Lua scripting, you can make three entities. One of them would be the placeable placeholder that could be rotated, and the other would be the two possible orientations of the container. When the placeholder is built, you catch it with the onentitybuilt event, get its orientation and delete it, and then create one of the two container entities in its place. It may sound a bit complicated, but it's actually fairly easy to do.
sillyfly
Smart Inserter
Smart Inserter
Posts: 1101
Joined: Sun May 04, 2014 11:29 am
Contact:

Re: Making rotatable non-square containers

Post by sillyfly »

Hmm... ok, this sounds promising.
Is there a way to catch a rotate request, though? What I mean is - I want the player to be able to hover their mouse over the container and press the "r" key and have it rotated. I suppose there would need to be some logic verifying the rotated position is not blocked by anything...

Edit: Ok, I realize this is automatically achieved by making the "fake" entity not a container, but rotatable! The first question still stands though.
[Also - when displaying the entity "ghost" for placing, I need to change whether the vertical or horizontal one is shown - is that possible as well?]
Kikkers
Fast Inserter
Fast Inserter
Posts: 109
Joined: Sun Jun 22, 2014 8:45 pm
Contact:

Re: Making rotatable non-square containers

Post by Kikkers »

Well, even steam engines (which are themselves rotatable) can't be rotated once placed. Maybe there's a built-in block that prevents non-square colliding entities from being rotated.
sillyfly
Smart Inserter
Smart Inserter
Posts: 1101
Joined: Sun May 04, 2014 11:29 am
Contact:

Re: Making rotatable non-square containers

Post by sillyfly »

Yes, I thought it maybe something like this. Ok, I will try the solution with the fake entity, and come back when I have failed/succeeded.
MrDrummer
Fast Inserter
Fast Inserter
Posts: 132
Joined: Sat Nov 22, 2014 2:51 pm
Contact:

Re: Making rotatable non-square containers

Post by MrDrummer »

I read this the other day, and an idea struck me:

Perhaps if you took the belt splitter for the rotating+picture mechanic and combine that with the storage mechanics?

i don't do mods or anything, but i assume the code would be similar for the 2x1 rotatable mechanics.
:D
Post Reply

Return to “Modding help”