Some stuff i cant undestand
Some stuff i cant undestand
First of all I'm sorry for my cry for help.
I'm trying to do a little mod of my own. It shoud be 1x2 chest i.e. ship container. A friend of mine helped with the graphics. Now i'm trying to make the code work. As usual for me i grab some other beautiful mods and frankensteinen them.
And so you know me and programming are on different ends of the stick.
So pleeeeeese help me couple things to understand
First is why the hell this is not working
table.insert(data.raw["technology"]["steel-processing"].effects,{type="unlock-recipe",recipe="ship-container"})
I see my item on the tech. Recipe is correct. Even locale works. But it does not apply in craft list. Not by hand not by assembler.
And the second one is big. It must have 2 different sprites cause it 1x2. I can figure this out how i shoud describe the entity.
I'm trying to do a little mod of my own. It shoud be 1x2 chest i.e. ship container. A friend of mine helped with the graphics. Now i'm trying to make the code work. As usual for me i grab some other beautiful mods and frankensteinen them.
And so you know me and programming are on different ends of the stick.
So pleeeeeese help me couple things to understand
First is why the hell this is not working
table.insert(data.raw["technology"]["steel-processing"].effects,{type="unlock-recipe",recipe="ship-container"})
I see my item on the tech. Recipe is correct. Even locale works. But it does not apply in craft list. Not by hand not by assembler.
And the second one is big. It must have 2 different sprites cause it 1x2. I can figure this out how i shoud describe the entity.
Re: Some stuff i cant undestand
First thing to double check is just that that your ship-container recipe isn't set with "hidden = true" in its prototype. If it is, that'll override any other enabling done by the game. If you post your code, we can probably tell you what's wrong within a few seconds.RavenlStl wrote: Sat Aug 24, 2019 4:33 pm First of all I'm sorry for my cry for help.
I'm trying to do a little mod of my own. It shoud be 1x2 chest i.e. ship container. A friend of mine helped with the graphics. Now i'm trying to make the code work. As usual for me i grab some other beautiful mods and frankensteinen them.
And so you know me and programming are on different ends of the stick.
So pleeeeeese help me couple things to understand
First is why the hell this is not working
table.insert(data.raw["technology"]["steel-processing"].effects,{type="unlock-recipe",recipe="ship-container"})
I see my item on the tech. Recipe is correct. Even locale works. But it does not apply in craft list. Not by hand not by assembler.
And the second one is big. It must have 2 different sprites cause it 1x2. I can figure this out how i shoud describe the entity.
Re: Some stuff i cant undestand
Code: Select all
data:extend(
{
{
type = "item",
name = "ship-container",
icon = "__ShipContainer__/graphics/icons/ship-container.png",
icon_size = 32,
subgroup = "storage",
order = "aab",
place_result = "ship-container",
stack_size = 10
},
}
)
Code: Select all
data:extend(
{
{
type = "recipe",
name = "ship-container",
enabled = false,
ingredients =
{
{"iron-plate", 12},
{"steel-plate", 8},
{"iron-gear-wheel", 2},
{"iron-rod", 2}
},
result = "ship-container"
},
}
)
Re: Some stuff i cant undestand
Did you add the recipe after you researched the tech? Try running /c game.player.force.reset_technology_effects() if you did.
Re: Some stuff i cant undestand
Yep! Worked just fine! Thanks a lot!Adamo wrote: Sat Aug 24, 2019 5:27 pm Did you add the recipe after you researched the tech? Try running /c game.player.force.reset_technology_effects() if you did.
Re: Some stuff i cant undestand
Great! As long as the recipe shows up in the tech tree, I think you can be confident that it will be enabled when someone researches the tech, but I've found the game to be inconsistent on whether it does this for new mods with recipes in techs that are already researched on the map. Well. not inconsistent, but I just haven't figured out the pattern, yet.
Last edited by Adamo on Sat Aug 24, 2019 5:36 pm, edited 1 time in total.
Re: Some stuff i cant undestand
Now the real stuff...
I got this
And i got this
And i'm too dumb to make it work together
I got this
Code: Select all
data:extend(
{
{
type = "container",
name = "ship-container",
icon = "__ShipContainer__/graphics/icons/ship-container.png",
icon_size = 64,
flags = {"placeable-neutral", "player-creation"},
minable = {mining_time = 0.2, result = "ship-container"},
inventory_size = 80,
max_health = 700,
corpse = "medium-remnants",
open_sound = { filename = "__base__/sound/metallic-chest-open.ogg", volume=0.65 },
close_sound = { filename = "__base__/sound/metallic-chest-close.ogg", volume = 0.7 },
vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.75 },
resistances = {{ type = "fire", percent = 90 }, { type = "impact", percent = 60 }},
collision_box = {{-0.70, -0.70}, {0.70, 0.70}},
selection_box = {{-1.0, -1.0}, {1.0, 1.0}},
fast_replaceable_group = "container",
scale_info_icons = 1,
picture =
{
layers =
{
{
filename = "__ShipContainer__/graphics/entity/ship-container.png",
priority = "extra-high",
width = 32,
height = 40,
shift = util.by_pixel(0, -1),
scale = 1,
},
{
filename = "__ShipContainer__/graphics/entity/ship-container-shadow.png",
priority = "extra-high",
width = 56,
height = 22,
shift = util.by_pixel(12, 15),
draw_as_shadow = true,
scale = 1,
}
}
},
circuit_wire_connection_point = circuit_connector_definitions["chest"].points,
circuit_connector_sprites = circuit_connector_definitions["chest"].sprites,
circuit_wire_max_distance = default_circuit_wire_max_distance
}
}
)
Code: Select all
picture = {
north = {
filename = "__ShipContainer__/graphics/entity/ship-container-h.png",
priority = "high",
shift = util.by_pixel(5, -18),
width = 128,
height = 80,
},
east = {
filename = "__ShipContainer__/graphics/entity/ship-container-v.png",
priority = "high",
shift = util.by_pixel(31, -5),
width = 64,
height = 144,
},
south = {
filename = "__ShipContainer__/graphics/entity/ship-container-h.png",
priority = "high",
shift = util.by_pixel(5, -18),
width = 128,
height = 80
},
filename = "__ShipContainer__/graphics/entity/ship-container-v.png",
priority = "high",
shift = util.by_pixel(31, -5),
width = 64,
height = 144,
}
}
Re: Some stuff i cant undestand
Well, the last entry in your rotating sprite set needs to be set by "west = {", exactly like the other entries in the table. You seem to be missing that line.
Re: Some stuff i cant undestand
Yeah its a mistypo,
but i got this two codes from different mods, and i really dont undertsnd how to cerrectly unite them and how to describe entity behavior.
but i got this two codes from different mods, and i really dont undertsnd how to cerrectly unite them and how to describe entity behavior.
Re: Some stuff i cant undestand
Have you tried just adding the "west = {" line where it needs to go, and then just removing the entire entry for the "picture" table in the first prototype and replacing it with the picture table in your second code snippet? I feel like it should work. You'll be removing the shadow, but one step at a time.RavenlStl wrote: Sat Aug 24, 2019 5:40 pm Yeah its a mistypo,
but i got this two codes from different mods, and i really dont undertsnd how to cerrectly unite them and how to describe entity behavior.
Re: Some stuff i cant undestand
Error while loading entity prototype "ship-container" (container): Key "filename" not found in poperty tree at ROOT.container.ship-container.picture
Code: Select all
data:extend(
{
{
type = "container",
name = "ship-container",
icon = "__ShipContainer__/graphics/icons/ship-container.png",
icon_size = 64,
flags = {"placeable-neutral", "player-creation"},
minable = {mining_time = 0.2, result = "ship-container"},
inventory_size = 80,
max_health = 700,
corpse = "medium-remnants",
open_sound = { filename = "__base__/sound/metallic-chest-open.ogg", volume=0.65 },
close_sound = { filename = "__base__/sound/metallic-chest-close.ogg", volume = 0.7 },
vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.75 },
resistances = {{ type = "fire", percent = 90 }, { type = "impact", percent = 60 }},
collision_box = {{-0.70, -0.70}, {0.70, 0.70}},
selection_box = {{-1.0, -1.0}, {1.0, 1.0}},
fast_replaceable_group = "container",
scale_info_icons = 1,
picture = {
north = {
filename = "__ShipContainer__/graphics/entity/ship-container-h.png",
priority = "high",
shift = util.by_pixel(5, -18),
width = 128,
height = 80,
},
east = {
filename = "__ShipContainer__/graphics/entity/ship-container-v.png",
priority = "high",
shift = util.by_pixel(31, -5),
width = 64,
height = 144,
},
south = {
filename = "__ShipContainer__/graphics/entity/ship-container-h.png",
priority = "high",
shift = util.by_pixel(5, -18),
width = 128,
height = 80
},
west = {
filename = "__ShipContainer__/graphics/entity/ship-container-v.png",
priority = "high",
shift = util.by_pixel(31, -5),
width = 64,
height = 144,
}
},
circuit_wire_connection_point = circuit_connector_definitions["chest"].points,
circuit_connector_sprites = circuit_connector_definitions["chest"].sprites,
circuit_wire_max_distance = default_circuit_wire_max_distance
}
}
)
Re: Some stuff i cant undestand
Oh, you know what? Look here: https://wiki.factorio.com/Prototype/Container
The container prototype only supports one picture, not a north,south,east,west 4-way sprite. Sorry. I don't think there's any way to take a sprite and turn it into a rotatable thing. You need a prototype that takes a 4-way sprite table to do that. You can still use layers to have shadows and other multi-layered sprites, but, doesn't look like you can do rotation. Here are all the things you can put in the picture table: https://wiki.factorio.com/Types/Sprite
One trick that maybe would work would be to put the 4way sprite into the integration_patch table and use an "empty" sprite for the sprite in "picture". That's a bit tricky and likely not recommended, but, as an advanced coder, I'd probably try it if I were in your position.
Another, likely better, option would be to see if another prototype other than "container" can still serve your purpose. One that takes a 4-way sprite table instead of a single picture sprite.
The container prototype only supports one picture, not a north,south,east,west 4-way sprite. Sorry. I don't think there's any way to take a sprite and turn it into a rotatable thing. You need a prototype that takes a 4-way sprite table to do that. You can still use layers to have shadows and other multi-layered sprites, but, doesn't look like you can do rotation. Here are all the things you can put in the picture table: https://wiki.factorio.com/Types/Sprite
One trick that maybe would work would be to put the 4way sprite into the integration_patch table and use an "empty" sprite for the sprite in "picture". That's a bit tricky and likely not recommended, but, as an advanced coder, I'd probably try it if I were in your position.
Another, likely better, option would be to see if another prototype other than "container" can still serve your purpose. One that takes a 4-way sprite table instead of a single picture sprite.
Re: Some stuff i cant undestand
Ok, at this point my mind is blown away)) For me its undoable, but anyway thanks a lot for the help!
Re: Some stuff i cant undestand
Well, it says pretty clearly the container prototype can't be rotated, but, you could consider just making two entities: a vertical one and a horizontal one. Or just choosing which direction you like more, and sticking to that. Then you would just make the picture table in your prototype call to that one file, either ship-container-v.png or ship-container-h.png.RavenlStl wrote: Sat Aug 24, 2019 6:21 pm Ok, at this point my mind is blown away)) For me its undoable, but anyway thanks a lot for the help!
Re: Some stuff i cant undestand
by 2 entities you mean 2 different items to craft or is the way for game to pick one of them depending on rotation?
Re: Some stuff i cant undestand
The simplest thing would just be to make two recipes, two items, and two entities -- one entity for each orientation -- and then add both recipes to the tech. This is because the container prototype doesn't allow rotating. Doing more than that will get tricky, but there are things you can try when you feel like you're ready. I would start with just making the two recipes, items, and entities, though.RavenlStl wrote: Sat Aug 24, 2019 7:56 pm by 2 entities you mean 2 different items to craft or is the way for game to pick one of them depending on rotation?
If you decide to do this, you'll be at step two, where you need to look at the selection_box and collision_box values in your entity prototypes, and give them the correct coordinates for the size of the 2x1 sprite you're using.
- BlueTemplar
- Smart Inserter
- Posts: 3237
- Joined: Fri Jun 08, 2018 2:16 pm
- Contact:
Re: Some stuff i cant undestand
Could rotation (at least in hand) be achieved with some scripting trickery ?
(see "rotation" of landfill tiles... in... Dectorio ? Or was it Sea Block ..?)
(Does the game even have in-built support for rotation of non-square entities ?)
(see "rotation" of landfill tiles... in... Dectorio ? Or was it Sea Block ..?)
(Does the game even have in-built support for rotation of non-square entities ?)
BobDiggity (mod-scenario-pack)
Re: Some stuff i cant undestand
I think so, yes. But before I mention the way that suggests itself to me, I point out that if I were solving your problem, I think I'd strongly look at finding another prototype that can pretend to be a container but also rotates. Here are all of the prototypes that are extended from EntityWithHealth:BlueTemplar wrote: Sun Aug 25, 2019 7:33 am Could rotation (at least in hand) be achieved with some scripting trickery ?
https://wiki.factorio.com/Prototype/Ent ... Extensions
If I were going to try to script a way to rotate this container, one possible way that suggests itself to me is to create the two entities, and then setup a custom-input data prototype, like
Code: Select all
data:extend({
{
type = "custom-input",
name = "rotate-ship-container",
key_sequence = "SHIFT + R",
consuming = "none"
}
})
Code: Select all
script.on_event("rotate-ship-container",function(event)
-- check if player.selected is a container
-- check if space is clear to rotate container
-- store contents of container in a table of itemstack objects
-- remove container
-- create new container
-- put contents of table of itemstack objects into the new container
end)
Unfortunately, I'm looking through here, and I'm not seeing one. But I am not the cleverest one around. I wonder if we could somehow make it work as a cargo wagon. Maybe there's a way to make a rail wagon not need to go on tracks? Then it would be a matter of sizing it and setting it to be placed on grid.