originalfoo / Proto

Like the Style mod, but for all other prototypes!
MIT License
0 stars 0 forks source link

`proto.recipe` #16

Open originalfoo opened 7 years ago

originalfoo commented 7 years ago

From forums - overload_multipler allows increased assembling machine input buffer.

  {
    type = "recipe",
    name = "gun-turret",
    enabled = false,
    energy_required = 10,
    ingredients =
    {
      {"iron-gear-wheel", 10},
      {"copper-plate", 10},
      {"iron-plate", 20}
    },
    result = "gun-turret",
    overload_multiplier = 20
  }
originalfoo commented 7 years ago

Set 'made in' field of a recipe: https://forums.factorio.com/viewtopic.php?f=25&t=32194

originalfoo commented 7 years ago

energy_required is the strange name for the crafting time of the recipe.

originalfoo commented 7 years ago

Recipes have similarities to technologies #2 , could potentially share similar definitions.

Draft tech proto for comparison:

proto.tech '<TechName>' {
  upgrade = <Boolean>; -- overlay "+" image on icon, hide on complete, default false
  icon = image.icon 'filename.png'; -- just a file path, mandatory?
  extends = '<TechName>'; -- base this tech on existing tech?
  requires = {
    tech = { '<TechName>', ... };
    packs = need '<Ingredient>' * <Number> + ...;
    duration = <Number>; -- time per pack, (what units?), default 60?
    batches = <Number>; -- how many packs? default 50?
  };
  provides = { -- optional
    effect.recipe '<RecipeName>'; -- type = 'unlock-recipe'
    effect.custom '<EffectType>' { <EffectSettings> }; -- any other type of effect
    -- modifier amount either numeric or string (eg. '0.2')
    effect.bonus '<BonusName>' * <Amount>; -- type = '<BonusName>'
    effect.ammoDamage '<AmmoCategory>' * <Amount>; -- type = 'ammo-damage'
    effect.ammoSpeed '<AmmoCategory>' * <Amount>; -- type = 'gun-speed'
    effect.turretAttack '<TurretName>' * <Amount>; -- type = 'turret-attack'
  };
  order = '<String>' -- need a better way of doing this
}
originalfoo commented 7 years ago

Draft recipe proto:

proto.recipe '<RecipeName'> {
  category = '<String>'; -- limit which assembly machines, etc, recipe can be made in
  consumes = {
    items = { amount, name, amount, name, ... };
    fluids = { amount, name, amount, name, ... };
    energy = <Number>;
  };
  enabled = <Boolean>;
  icon = <image.icon>; -- defaults to icon of <Produces> if single result
  order = '<String>';
  produces = {
    items = { amount, name, amount, name, ... };
    fluids = { amount, name, amount, name, ... };
    batches = <Number>;
  };
  pasteMultiplier = <Number>; -- requester_paste_multiplier
  subgroup = '<String>';
}

Fluid ingredients have different format:

{ amount = 5, name = "water", type = "fluid" }

That could be greatly simplified by checking to see if ingredient name is listed as a fluid, and if so create the hashmap.

Note: Items can also use the longform:

{ amount = 1, name = "steel-plate", type = "item" }

Chemistry category recipes also have a main_product = '' property; not sure what it does (always seems to be empty string). Going to ignore it for now.

originalfoo commented 7 years ago

Recipe categories: #5

  ["recipe-category"] = {
    ["advanced-crafting"] = {
      name = "advanced-crafting",
      type = "recipe-category"
    },
    chemistry = {
      name = "chemistry",
      type = "recipe-category"
    },
    crafting = {
      name = "crafting",
      type = "recipe-category"
    },
    ["crafting-with-fluid"] = {
      name = "crafting-with-fluid",
      type = "recipe-category"
    },
    ["oil-processing"] = {
      name = "oil-processing",
      type = "recipe-category"
    },
    ["rocket-building"] = {
      name = "rocket-building",
      type = "recipe-category"
    },
    smelting = {
      name = "smelting",
      type = "recipe-category"
    }
  },
originalfoo commented 7 years ago

There's potentially also a flags = { 'hidden' } or hidden = true setting for recipes.

originalfoo commented 7 years ago

main_product does have an effect, see forums

When not nil, the following props become mandatory (as they can't be determined from associated item protos): name, icon, subgroup and order

originalfoo commented 7 years ago

Apparently recipe output can have probability set:

    results=
    {
      {type="fluid", name="coal-gas", amount=4},
      {type="fluid", name="tar", amount=5},
      {type="item", name="iron-oxide", amount=1, probability=0.5},
      {type="item", name="coke", amount=4},
    },

Also result_count property...?

originalfoo commented 7 years ago

Locale keys are somewhat complex for recipes:

{"recipe-name.<recipe name>"}, if such key is not found -> {"item-name.<product's item name"}, if not found -> {"entity-name.<product place_result's entity-name>"}, if not found -> "unknown key: entity-name...."

See forum topic