Making rotatable non-square containers
Making rotatable non-square containers
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!
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!
Re: Making rotatable non-square containers
Try with this, i'm not sure
mm... or this...
Can use base entities for examples, like splitter, is a 2x1 entity rotable.
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}
},
},
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
}
},
Re: Making rotatable non-square containers
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.)
I guess the problem is that a "container" requires a "picture" node which must have a "filename" node (and not north/east etc.)
Re: Making rotatable non-square containers
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!
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!
Re: Making rotatable non-square containers
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?
Do you know if anyone requested such a feature to be added? Or could you provide a link to that other mod you mentioned?
Re: Making rotatable non-square containers
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
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
Re: Making rotatable non-square containers
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.
Re: Making rotatable non-square containers
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?]
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?]
Re: Making rotatable non-square containers
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.
Re: Making rotatable non-square containers
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.
Re: Making rotatable non-square containers
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.
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.