Easy assembling machine remake?

Place to get help with not working mods / modding interface.
Post Reply
donoya
Fast Inserter
Fast Inserter
Posts: 119
Joined: Thu Dec 04, 2014 10:55 pm
Contact:

Easy assembling machine remake?

Post by donoya »

I'm having trouble understanding this coding language. I want to be able to make a clone of the vanilla assembling machine with only a change in the recipe category set that it uses. I have a somewhat basic understanding of java code, but it doesn't seem to help when I'm reading the wiki or looking through the posts. I think it would be easy if it were java code (I'd just have to make the new class extend the class for the assembling machine and change the category variable). But seeing as how it's not java code, I don't even know where to start. Help would be greatly appreciated here.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Easy assembling machine remake?

Post by DaveMcW »

The classes are not exposed for editing. All you can do is set some properties in the data files (data/base/prototypes/entity).

The field you want to edit is called crafting_categories.

donoya
Fast Inserter
Fast Inserter
Posts: 119
Joined: Thu Dec 04, 2014 10:55 pm
Contact:

Re: Easy assembling machine remake?

Post by donoya »

But what I want to know is how I edit that to do what I want.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Easy assembling machine remake?

Post by DaveMcW »

Read the tutorial in the stickied thread?

donoya
Fast Inserter
Fast Inserter
Posts: 119
Joined: Thu Dec 04, 2014 10:55 pm
Contact:

Re: Easy assembling machine remake?

Post by donoya »

What sticky thread? Sorry if the answer is obvious, but I can't tell what the difference is (unless you are referring to the one about mod help references, in which case, I looked at the wiki pages that were linked and it was too confusing for me.)

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Easy assembling machine remake?

Post by DaveMcW »

The thread right above this one.

donoya
Fast Inserter
Fast Inserter
Posts: 119
Joined: Thu Dec 04, 2014 10:55 pm
Contact:

Re: Easy assembling machine remake?

Post by donoya »

Well, the modding tutorial does seem to cover the basic structure of the code, but it didn't quite tell me how to make structures. But at least now I have some knowledge on the language. So, is there any help about how to remake the assembling machine?

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

Re: Easy assembling machine remake?

Post by L0771 »

Factorio\data\base\prototypes\entity\demo-entities.lua > line 1876

Code: Select all

{
    type = "assembling-machine",
    name = "assembling-machine-1",
    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",
    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",
      width = 99,
      height = 102,
      frame_count = 32,
      line_length = 8,
      shift = {0.25, -0.1}
    },
    crafting_categories = {"crafting"},
    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,
    }
  },
Can change what you want and can add some properties.
You can't create an entity new, but current entities are extensive

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Easy assembling machine remake?

Post by Rseding91 »

When you want to do what you're trying to do the fastest (and most reliable) way is to deepcopy the existing data.raw entry and make changes to that.

Something like this in your data.lua (or other staged variant):

Code: Select all

local myAssemblyMachine = util.table.deepcopy(data.raw["assembling-machine"]["assembling-machine-1"])

myAssemblyMachine["name"] = "assembling-machine-test"
myAssemblyMachine["crafting_categories"] = {"newcraftingcategory"}

data:extend({myAssemblyMachine})
You will of course need to define the "newcraftingcategory" unless you're simply switching the category to a different existing one.
If you want to get ahold of me I'm almost always on Discord.

donoya
Fast Inserter
Fast Inserter
Posts: 119
Joined: Thu Dec 04, 2014 10:55 pm
Contact:

Re: Easy assembling machine remake?

Post by donoya »

Rseding91 wrote:When you want to do what you're trying to do the fastest (and most reliable) way is to deepcopy the existing data.raw entry and make changes to that.

Something like this in your data.lua (or other staged variant):

Code: Select all

local myAssemblyMachine = util.table.deepcopy(data.raw["assembling-machine"]["assembling-machine-1"])

myAssemblyMachine["name"] = "assembling-machine-test"
myAssemblyMachine["crafting_categories"] = {"newcraftingcategory"}

data:extend({myAssemblyMachine})
You will of course need to define the "newcraftingcategory" unless you're simply switching the category to a different existing one.
This is precisely what I was looking for. Now how do I define the catagory?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Easy assembling machine remake?

Post by Rseding91 »

donoya wrote:
Rseding91 wrote:When you want to do what you're trying to do the fastest (and most reliable) way is to deepcopy the existing data.raw entry and make changes to that.

Something like this in your data.lua (or other staged variant):

Code: Select all

local myAssemblyMachine = util.table.deepcopy(data.raw["assembling-machine"]["assembling-machine-1"])

myAssemblyMachine["name"] = "assembling-machine-test"
myAssemblyMachine["crafting_categories"] = {"newcraftingcategory"}

data:extend({myAssemblyMachine})
You will of course need to define the "newcraftingcategory" unless you're simply switching the category to a different existing one.
This is precisely what I was looking for. Now how do I define the catagory?

Code: Select all

data:extend({{type = "recipe-category", name = "newcraftingcategory"}})
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Modding help”