Page 1 of 1

Easy assembling machine remake?

Posted: Tue Dec 16, 2014 1:56 am
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.

Re: Easy assembling machine remake?

Posted: Tue Dec 16, 2014 2:23 am
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.

Re: Easy assembling machine remake?

Posted: Tue Dec 16, 2014 3:11 am
by donoya
But what I want to know is how I edit that to do what I want.

Re: Easy assembling machine remake?

Posted: Tue Dec 16, 2014 4:09 am
by DaveMcW
Read the tutorial in the stickied thread?

Re: Easy assembling machine remake?

Posted: Wed Dec 17, 2014 12:20 am
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.)

Re: Easy assembling machine remake?

Posted: Wed Dec 17, 2014 12:42 am
by DaveMcW
The thread right above this one.

Re: Easy assembling machine remake?

Posted: Wed Dec 17, 2014 1:36 am
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?

Re: Easy assembling machine remake?

Posted: Wed Dec 17, 2014 2:31 am
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

Re: Easy assembling machine remake?

Posted: Wed Dec 17, 2014 1:50 pm
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.

Re: Easy assembling machine remake?

Posted: Wed Dec 17, 2014 4:25 pm
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?

Re: Easy assembling machine remake?

Posted: Wed Dec 17, 2014 5:54 pm
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"}})