dennisjenkins75 / digiline_craftdb

Minetest mod for a digiline queryable database holding all regular and technic crafting recipes.
GNU General Public License v3.0
2 stars 2 forks source link

Format `craft` table for autocrafter #11

Closed OgelGames closed 3 years ago

OgelGames commented 3 years ago

Currently the craftdb sends crafting recipes like this:

{
  action = "normal",
  craft = {
    width = 3,
    grid = {
      "technic:mv_battery_box0",
      "technic:mv_battery_box0",
      "technic:mv_battery_box0",
      "technic:mv_battery_box0",
      "technic:hv_transformer",
      "technic:mv_battery_box0",
      [8] = "technic:hv_cable"
    }
  },
  inputs = {
    ["technic:hv_cable"] = 1,
    ["technic:mv_battery_box0"] = 5,
    ["technic:hv_transformer"] = 1
  },
  outputs = {
    ["technic:hv_battery_box0"] = 1
  },
  time = 1
}

However, for sending the recipe to an autocrafter, the craft table needs to be reformatted like this:

craft = {
  {"technic:mv_battery_box0", "technic:mv_battery_box0", "technic:mv_battery_box0"},
  {"technic:mv_battery_box0", "technic:hv_transformer", "technic:mv_battery_box0"},
  {"", "technic:hv_cable", ""}
}

Though this requires very little code to do, IMO it would make more sense to send the craft table in the correct format like this:

{
  action = "normal",
  craft = {
    {"technic:mv_battery_box0", "technic:mv_battery_box0", "technic:mv_battery_box0"},
    {"technic:mv_battery_box0", "technic:hv_transformer", "technic:mv_battery_box0"},
    {"", "technic:hv_cable", ""}
  },
  inputs = {
    ["technic:hv_cable"] = 1,
    ["technic:mv_battery_box0"] = 5,
    ["technic:hv_transformer"] = 1
  },
  outputs = {
    ["technic:hv_battery_box0"] = 1
  },
  time = 1
}
dennisjenkins75 commented 3 years ago

Good point. Looks like "craft" is populated in the function CraftDB:canonicalize_regular_recipe, so the change should be made there.