Can't use charges from car batteries as part of a recipe. How to fix?

I tried setting up a recipe to use charges from any of the various types of vehicle batteries, but the game doesn’t see that you have a charged battery when you go to craft it. The recipe shows up in the crafting menu as expected: “car battery (1 charge) OR small storage battery (1 charge) …”

Any ideas what might be going on here? Presumably this is outside the realm of JSON, what cpp file would I dig through to try to debug and solve this?

Do you mind posting the recipe?

Sure, not a problem.

  {
    "result": "tin",
    "type": "recipe",
    "byproducts": [ [ "steel_chunk" ] ],
    "category": "CC_OTHER",
    "subcategory": "CSC_OTHER_MATERIALS",
    "skill_used": "fabrication",
    "difficulty": 2,
    "time": 30000,
    "batch_time_factors": [ 50, 2 ],
    "autolearn": true,
    "qualities" : [ { "id":"CONTAIN","level":1 } ],
    "using": [ [ "electric_current", 1 ] ],
    "components": [ [ [ "acid", 1 ] ], [ [ "water", 3 ], [ "water_clean", 3 ] ], [ [ "can_food_unsealed", 1 ] ] ]
  }

“electric current” is defined in data/json/requirements/toolsets.json as follows:

  {
    "id": "electric_current",
    "type": "requirement",
    "//": "A source of electricity and something to apply it with",
    "tools": [
      [ [ "battery_car", 1 ], [ "battery_motorbike", 1 ], [ "small_storage_battery", 1 ], [ "medium_storage_battery", 1 ], [ "storage_battery", 1 ] ],
      [ [ "cable", -1 ] ]
    ]
  }

Side note, if anyone’s curious, the recipe is based on this patent.

I have no personal experience using that particular indicator so unfortunately the only fix I can give is to assign those batteries as tools and use the charge in that sense. A bit hacky but it’s all that I can think of right now.

Is this what you mean by “assign as tools”?

  {
    "result": "tin",
    "type": "recipe",
    "byproducts": [ [ "steel_chunk" ] ],
    "category": "CC_OTHER",
    "subcategory": "CSC_OTHER_MATERIALS",
    "skill_used": "fabrication",
    "difficulty": 2,
    "time": 30000,
    "batch_time_factors": [ 50, 2 ],
    "autolearn": true,
    "qualities" : [ { "id":"CONTAIN","level":1 } ],
    "tools": [
      [ [ "battery_car", 1 ], [ "battery_motorbike", 1 ], [ "small_storage_battery", 1 ], [ "medium_storage_battery", 1 ], [ "storage_battery", 1 ] ],
      [ [ "cable", -1 ] ]
    ],
    "components": [ [ [ "acid", 1 ] ], [ [ "water", 3 ], [ "water_clean", 3 ] ], [ [ "can_food_unsealed", 1 ] ] ]
  }

That didn’t work either, batteries are still seen as not being available. As before, if I don’t require charges to be consumed, everything works fine.

Ah, I see, the vehicle batteries are defined as magazines, not tools. Unfortunately, switching them to tools breaks their functionality (expected) and presumably, consuming ammo from magazines in a crafting recipe is not supported in the code. Does anyone know where I would go to add said support? I am still pretty unfamiliar with the source code so I don’t really know where to start.

You might need to define a “power supply” tool that can accept car batteries as a magazine. See the acetylene torch as an example of tools that accept magazines.

1 Like

I still don’t see why this shouldn’t work I mean if it works for tools such as welders where they are filled with batteries in a not same sense but similar why?

Magazines are containers. They technically don’t have charges, just contain charges of ammo.

What are the charges for car batteries? Regular batteries or something else.

Yes, car batteries are magazines that use batteries as ammo. However they have the tags “NO_RELOAD” and “NO_UNLOAD” so that you can’t unload and reload them like normal magazines.

EDIT: Almost forgot, good thinking @Lazy_lizard, I will definitely use your suggestion. Thanks for the help!

1 Like