Skip to main content

info.Itemname

Item = {}
local item_metatab = {}
doLogger = 1
log = require "logger"

function Item.new(Itemname,Itemsize,Itemdamage,Itemslot)
        local info = {}
        info.Itemname = Itemname
        info.Itemsize = Itemsize
        info.Itemdamage = Itemdamage
info.Itemslot = Itemslot
        setmetatable(info,item_metatab)
        -- "and it behaves like a Item!"
        return info
        end

function Item.tostring(which)
        local say = "Item " .. which.Itemname ..
                " dmg " .. which.Itemsize .. " cnt " .. which.Itemdamage .. " slot " .. which.Itemslot
        return say
        end

function Item.getvolume(which)
        local volis = which.x * which.y * which.z
        return volis
        end

-- "print" uses Item.tostring
item_metatab.__tostring = Item.tostring

-- If you can't find a function, go to the one in Item
item_metatab.__index = Item

-- ------------------------------------------------
-- end item
--start recipe
--------------------------------------------------
Recipe = {}
local item_metatab = {}
function Recipe.new(recipe_Name, ign1,ign2,ign3,ign4,ign5,ign6,ign7,ign8,ign9)
        local nase = {}
nase.recipe_Name = recipe_Name
        nase.ign1 = ign1
nase.ign1cnt = ign1cnt
        nase.ign2 = ign2
nase.ign2cnt = ign2cnt
        nase.ign3 = ign3
nase.ign1cnt = ign3cnt
nase.ign4 = ign4
nase.ign4cnt = ign4cnt
nase.ign5 = ign5
nase.ign5cnt = ign5cnt
nase.ign6 = ign6
nase.ign6cnt = ign6cnt
nase.ign7 = ign7
nase.ign7cnt = ign7cnt
nase.ign8 = ign8
nase.ign8cnt = ign8cnt
nase.ign9 = ign9
nase.ign9cnt = ign9cnt
        setmetatable(nase,item_metatab)
        -- "and it behaves like a Recipe!"
        return nase
        end

function Recipe.tostring(which)
        local say2 = "Recipe " ..recipe_Name .. " with ".. which.ign1 .. " " .. which.ign2 .. " " .. which.ign3 .. " " .. which.ign4 .. " " .. which.ign5 .. " " .. which.ign6 .. " " .. which.ign7 .. " " .. which.ign8 .. " "
        return say
        end

-- "print" uses Recipe.tostring
item_metatab.__tostring = Recipe.tostring

-- If you can't find a function, go to the one in Recipe
item_metatab.__index = Recipe
------------------------------------------------
--end recipe
-- ------------------------------------------------
-- Below stuff """ makes use of that class """
-- ------------------------------------------------

Items = {}
Recipes = {}

local component = require("component")
local sides = require("sides")
 
local slot = 1
--robot can only read front.....
local input = sides.front
local inv = component.inventory_controller
local invSize = inv.getInventorySize(sides.front)
local oneitem = nil

table.insert(Recipes,Recipe.new("wyvern_core","minecraft:nether_star",2,"minecraft:emerald_block",1,"draconicevolution:draconium_block",2, "draconicevolution:draconic_core", 5 ,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil))


 

print ("Invsize: ", invSize)

for i = invSize,2,-1
do
--print (i)
oneitem = inv.getStackInSlot(input,i)
   if oneitem then

table.insert(Items,Item.new(oneitem.name,oneitem.size,oneitem.damage,i))
--log.debug("Item name: ", oneitem.name)
--log.debug("Item count: ", oneitem.size)
--log.debug("Item damage: ", oneitem.damage)
if oneitem.name == "minecraft:bread" then
print("bread")
else
print("nope")
end
else
--print("Slot " .. i .. " is empty")
end
end
--debug
for _,recipeobj in ipairs(Recipes) do
print ("searching for " .. recipeobj.recipe_Name)
for _,itemobj in ipairs(Items) do
        string = itemobj.Itemname
        print (_,string)
if recipeobj.ign1 ==itemobj.Itemname then
print ("found: " .. recipeobj.ign1)
        end
end
--string = component:tostring()
--print (_,string)
end