How to read a table from file

Started by redstonegenius, Sep 28, 2021, 07:25 PM

Previous topic - Next topic

redstonegenius

So I am trying to make a api that basically does craftingAPI.craftFromName(<itemName>, <amount>) and have it automatically find the recipe from a dictionary and craft the item. I already got it so It can craft if given the recipe in the form of a 3x3 array, but I am having trouble with the dictionary part.

Basically I want two type of dictionaries, recipe and material type. Material types are items that can be replaced without altering what get outputted, like the types of planks used for a chest. and I want the recipies in the dicitonaries to look something like this

minecraft:piston={"minecraft:oak_planks","minecraft:oak_planks","minecraft:oak_planks"},{"minecraft:cobblestone","minecraft:iron_ingot","minecraft:cobblestone"},{"minecraft:cobblestone","minecraft:redstone","minecraft:cobblestone"}
minecraft:dropper={{"minecraft:cobblestone","minecraft:cobblestone","minecraft:cobblestone"},{"minecraft:cobblestone","minecraft:air","minecraft:cobblestone"},{"minecraft:cobblestone","minecraft:redstone","minecraft:cobblestone"}}

The thing is, I don't have a clue how to turn the table that is being inputed as a string by the file.read() function into a actual table that I can have the craftingAPI use.

How can I convert these strings into a proper table

Lupus590