Hey people.
I run into some wierd thing in my opinion. If i coded a recipe like for a sub machine gun there is enabled = false for default. If i add a new crafting category for it to be build in one of my new factories it isn't shown up.
This is with every item i do this category. Otherwise if there isn't the enabled =false line everything works fine.
Do i do something wrong?
Oh and btw. my categories work
{
type = "recipe",
name = "submachine-gun",
category = "military-crafting",
enabled = "false",
energy_required = 3,
ingredients =
{
{"iron-gear-wheel", 10},
{"copper-plate", 5},
{"iron-plate", 10}
},
result = "submachine-gun"
},
Re: Recipe categories
Posted: Tue Sep 30, 2014 2:01 pm
by FreeER
Not exactly. First, just to be sure, enabled = false makes it so that the recipe is not shown by default, if the category is empty (or none of the recipes are enabled) then it won't be displayed. Recipes need to be set enabled during the game (typically with a technology through research, but control.lua/console can unlock it with game.player.force.recipes[recipe_name].enabled = true).
However, I'd imagine the real problem is that assembling machines have a list of categories that they can craft from (specified in prototypes as crafting_categories), so if you want them to be able to craft from your category you'd need to add your category name to their list. something like the following should work:
for name, prototype in pairs(data.raw["assembling-machine"] do
if name:find("assembling%-machine") then -- only for assembling-machine types with the text assembling-machine in their name
table.insert(prototype.crafting_categories, "your_crafting_category_name")
end
end
Re: Recipe categories
Posted: Wed Oct 01, 2014 10:56 am
by Phakx
So it was false to add my crafting categories in recipe-category.lua?
So i create a new .lua file called "crafting-categories" and leave it blank. So now everything loads but nothing changed.
I really don't know what i'm doing wrong
Only to understand this right:
This code you posted inserts a new table inside my crafting-categories.lua so the assembling machine like my "MilitaryBuilder" (this is the factory) could be used to craft the sub-machine-gun if i unlock the research for it. None other assembling machine has the recipe for this weapon anymore?
So i add in my recipe.lua a new category to the "radar" to be only build inside of my MilitaryBuilder.
This is the code for it:
{
type = "recipe",
name = "radar",
category = "military-crafting",
ingredients =
{
{"cabling", 10},
{"iron-gear-wheel", 5},
{"iron-stick", 10},
{"iron-plate", 20},
{"stone-brick", 20},
},
result = "radar"
},
But if i go into the game it will show me that it is locked and have to be build inside of simething, but it doesn't show me my Builder.
Re: Recipe categories
Posted: Thu Oct 02, 2014 2:34 pm
by Phakx
I tried but it didn't show up in my militaryBuilder
Re: Recipe categories
Posted: Fri Oct 03, 2014 4:49 pm
by FreeER
for recipes enabled controls whether the recipe will be unlocked at the start of the game or not. If it is set to false (the default is true) then it is not unlocked (and thus not displayed in the crafting menus) and it will need to be unlocked in-game using research (added via a technology prototype, if you need to, see data\base\prototypes\technology\technology.lua). If you want only your military builder entity to be able to craft those recipes then you do need the recipe-category and you also need to add that recipe-category name to the military builder's "crafting_categories" table. The recipe will only not show the crafter if it can be made in anything or if there are no machines with it's category in their "crafting_categories" table. The for loop I shared is designed to add a crafting category name (of "your_crafting_category_name", which should be replaced with whatever you used) to the crafting_categories table of all assembling machines with the text "assembling-machine" in their name, you'd only use it if you wanted other assembling machines to be able to craft those recipes.
data:extend({
{
type = "recipe-category",
name = "military-crafting"
},
{
type = "assembling-machine",
name = "military-assembling-machine",
icon = "__base__/graphics/icons/assembling-machine-1.png",
flags = {"placeable-neutral", "placeable-player", "player-creation"},
minable = {hardness = 0.2, mining_time = 0.5, result = "assembling-machine-1"},
max_health = 200,
corpse = "big-remnants",
dying_explosion = "huge-explosion",
order = "whatever",
resistances =
{
{
type = "fire",
percent = 70
}
},
collision_box = {{-1.2, -1.2}, {1.2, 1.2}},
selection_box = {{-1.5, -1.5}, {1.5, 1.5}},
fast_replaceable_group = "assembling-machine",
animation =
{
filename = "__base__/graphics/entity/assembling-machine-1/assembling-machine-1.png",
priority="high",
frame_width = 99,
frame_height = 102,
frame_count = 32,
line_length = 8,
shift = {0.25, -0.1}
},
crafting_categories = {"crafting", "military-crafting"}, -- remove "crafting" if you don't want it to craft other recipes
crafting_speed = 0.5,
energy_source =
{
type = "electric",
usage_priority = "secondary-input",
emissions = 0.05 / 1.5
},
energy_usage = "90kW",
ingredient_count = 2,
open_sound = { filename = "__base__/sound/machine-open.ogg", volume = 0.85 },
close_sound = { filename = "__base__/sound/machine-close.ogg", volume = 0.75 },
working_sound =
{
sound = {
{
filename = "__base__/sound/assembling-machine-t1-1.ogg",
volume = 0.8
},
{
filename = "__base__/sound/assembling-machine-t1-2.ogg",
volume = 0.8
},
},
idle_sound = { filename = "__base__/sound/idle1.ogg", volume = 0.6 },
apparent_volume = 1.5,
}
},
{
type = "recipe",
name = "aradar",
category = "military-crafting",
-- enabled = false, -- commented out for testing.
ingredients =
{
{"iron-plate", 20}
},
result = "radar"
}
})
for name, prototype in pairs(data.raw["assembling-machine"]) do -- remove this for loop if you only want your military builder to be able to make it.
if name:find("assembling%-machine") then -- only for assembling-machine types with the text assembling-machine in their name
table.insert(prototype.crafting_categories, "military-crafting")
end
end
Re: Recipe categories
Posted: Sat Oct 04, 2014 8:32 pm
by Phakx
I does this. Everything works fine. I create a technology but what my problem is for example the radar. I added the "military-crafting" in my category.lua
In this case if i added category = "military-crafting" node to the radar it should be only be craftable at assembling machines which has the category of "military-crafting".
I don't know why but several items work like the pistol but not the radar. I test it with diffrent items. It doesn't work with everything. Even if i enabled it via technology. If you want i could send you my category and item.lua to check. it just don't show up inside of my builder
EDIT: i added your lower code in a control.lua 2 days ago as you send it to me. but it doesn't solve my problem do i have to add it at the item i want to add into my builder? i mean inside of { } it should load from my control.lua
Re: Recipe categories
Posted: Sat Oct 04, 2014 10:00 pm
by FreeER
Phakx wrote:EDIT: i added your lower code in a control.lua 2 days ago as you send it to me.
all the code I've posted would belong in the data portion of your mod (whether directly in data.lua or a file required by it). But yeah, send me the code and I'll look and see why it's not working as expected.
Re: Recipe categories
Posted: Sun Oct 05, 2014 10:22 am
by Phakx
So if i create a control.lua and add the code inside of it it won't work?
I mean this could be the reason. I try this out and give you later response
Re: Recipe categories
Posted: Sun Oct 05, 2014 10:53 am
by Phakx
Okay. this is what i add in a new .lua file i called "builder":