Entity Modification

Place to get help with not working mods / modding interface.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2883
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Entity Modification

Post by darkfrei »

DiegoPro77 wrote:
Tue Mar 12, 2019 9:14 pm
Could you help me please?

Code: Select all

local ores = {"iron", "copper", "uranium"}
local recipe_chain = {"ore", "dust", "enriched", "deoxidized", "particle", "smelted", "plate"}
local mod_name = '__My_Mod_Name_For_Ores_Enrichment__' -- you are need to change the mod name

local recipe_category = "enriching" -- nice name for enrichment

data:extend({
  {
    type = "recipe-category",
    name = recipe_category
  }
})

table.insert (data.raw["assembling-machine"].centrifuge.crafting_categories, recipe_category) -- for example in centrifuge

for i, ore_name in pairs (ores) do
  for j = 2, #recipe_chain do
    local name = ore_name .. "-" .. recipe_chain[j]
    local ingredient_name = ore_name .. "-" .. recipe_chain[j-1]
    data:extend({
      {
        type = "recipe", 
        category = recipe_category,
        name = name,
        enabled = "true",
        energy_requied = 3,
        ingredients =
        {
          {ingredient_name, 4}
        },
        results = {{name = name, type = "item", amount = 3}},
      }
    })
    if not data.raw.item[name] then -- add item if you haven't it
      data:extend({
        {
          type = "item",
          name = name,
          icon = mod_name.."/graphics/icons/"..name..".png", -- you are need to add icons here
          icon_size = 32,
          subgroup = "raw-resource",
          order = "rc-"..i..'-'..j,
          stack_size = 100
        }
      })
    end
  end
end
Just rename the mod_name, add icons 32x32 to the folder.
Attachments
2019-03-12 22_56_00-D__Factorio_0.17_factorio-current.log - Notepad++.png
2019-03-12 22_56_00-D__Factorio_0.17_factorio-current.log - Notepad++.png (27.77 KiB) Viewed 516 times
data-final-fixes.lua
(1.42 KiB) Downloaded 13 times

User avatar
DiegoPro77
Fast Inserter
Fast Inserter
Posts: 153
Joined: Tue Feb 20, 2018 1:40 pm
Contact:

Re: Entity Modification

Post by DiegoPro77 »

Perfect, now it works with dusts.

This type of coding will be very useful for me, as i need a method for fast create recipes and, who knows, compatibilities too, as i'll use it in many other processes too.

Here's the result, for now i've omitted the data.raw.item part as i've already created them:

Code: Select all

mod_name = "__Dp77s-RealFactory-Core__"

local ores = {"iron", "copper", "olivine", "chalcopyrite"}
local recipe_chain = {"ore", "dust"}

local recipe_category = "steam_spalling"

--Thanks to Darkfrei and Bob for this piece of code--

for i, ore_name in pairs (ores) do
  for j = 2, #recipe_chain do
    local name = ore_name .. "-" .. recipe_chain[j]
    local ingredient_name = ore_name .. "-" .. recipe_chain[j-1]
    data:extend({
      {
        type = "recipe", 
        icon = mod_name.."/graphics/icons/"..name..".png",
		icon_size = 32,
        category = recipe_category,
		subgroup = "steam_spalling",
        name = name,
        enabled = "true",
        energy_requied = 7,
        ingredients =
        {
          {ingredient_name, 3}
        },
        results = 
		{
			{ name = name, type = "item", amount = 3 },
			{ name = "crushed-stone", type = "item", amount = 5 },
		},
      }
    })
  end
end
Thank you Darkfrei, you and bob will be mentioned in the description of the modpack for your support.
_DiegoPro77
My Discord page centered around my modpacks: https://discord.gg/6NGYQdX - My mods: https://mods.factorio.com/user/diegopro77
"Anyone who has never made a mistake has never tried anything new." A.Einstein
Expanding your game experience since 2018

User avatar
DiegoPro77
Fast Inserter
Fast Inserter
Posts: 153
Joined: Tue Feb 20, 2018 1:40 pm
Contact:

Re: Entity Modification

Post by DiegoPro77 »

Another thing on entities,

is there a method for creating machines that don't need power for work - and not burner-like?
_DiegoPro77
My Discord page centered around my modpacks: https://discord.gg/6NGYQdX - My mods: https://mods.factorio.com/user/diegopro77
"Anyone who has never made a mistake has never tried anything new." A.Einstein
Expanding your game experience since 2018

Bilka
Factorio Staff
Factorio Staff
Posts: 2790
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Entity Modification

Post by Bilka »

Use the void energy source type.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2883
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Entity Modification

Post by darkfrei »

DiegoPro77 wrote:
Fri Mar 29, 2019 7:02 pm
Another thing on entities,

is there a method for creating machines that don't need power for work - and not burner-like?
_DiegoPro77
Here's the mod for it https://mods.factorio.com/mod/NoEnergyRequired

User avatar
DiegoPro77
Fast Inserter
Fast Inserter
Posts: 153
Joined: Tue Feb 20, 2018 1:40 pm
Contact:

Re: Entity Modification

Post by DiegoPro77 »

Thank you bilka, I didn't notice this feature.
_DiegoPro77
My Discord page centered around my modpacks: https://discord.gg/6NGYQdX - My mods: https://mods.factorio.com/user/diegopro77
"Anyone who has never made a mistake has never tried anything new." A.Einstein
Expanding your game experience since 2018

Post Reply

Return to “Modding help”