fixed groups

This commit is contained in:
ksjdragon 2015-08-09 17:31:49 -04:00
parent dd3f8dfff0
commit ef867e4615

@ -38,7 +38,7 @@ local emcs = {
-- Precise Value (of lump): 442 -- Precise Value (of lump): 442
gold_lump = 488, gold_lump = 488,
-- Precise Value: 420 -- Precise Value: 420
mese_crystal = 425, mese_crystal = 423,
-- Precise Value: 848 -- Precise Value: 848
diamond = 976, diamond = 976,
@ -87,15 +87,15 @@ end
-- Add EMC values to raw materials. -- Add EMC values to raw materials.
for modname, itemlist in pairs(emcs) do for modname, itemlist in pairs(emcs) do
for itemname, emcvalue in pairs(itemlist) do for itemname, emcvalue in pairs(itemlist) do
minetest.override_item(modname..":"..itemname, { minetest.override_item(modname..":"..itemname, {
description = minetest.registered_items[modname..":"..itemname].description.."\nEMC Value: "..emcvalue, description = minetest.registered_items[modname..":"..itemname].description.."\nEMC Value: "..emcvalue,
emc = emcvalue, emc = emcvalue,
}) })
end end
end end
for i=1,10 do for i = 1,10 do
for _, itemname in pairs(registered_items) do for _, itemname in pairs(registered_items) do
if itemname ~= "" if itemname ~= ""
and itemname ~= ":" and itemname ~= ":"
@ -105,26 +105,18 @@ for i=1,10 do
for _, recipe in pairs(minetest.get_all_craft_recipes(itemname)) do for _, recipe in pairs(minetest.get_all_craft_recipes(itemname)) do
local emcvalue = 0 local emcvalue = 0
if recipe.type == "cooking" and minetest.registered_items[recipe.items[1]] ~= nil and minetest.registered_items[recipe.items[1]].emc then
if recipe.type == "cooking" and minetest.registered_items[recipe.items[1].emc] ~= nil then emcvalue = (minetest.registered_items[recipe.items[1]].emc * 1.5)-- Change to cooktime eventually.
emcvalue = minetest.registered_items[recipe.items[1]].emc * 1.5 print(itemname, emcvalue)
-- table.insert(exceptions, itemname) elseif minetest.registered_items[recipe.output:split(" ")[1]].emc == nil then
else
for _,item in pairs(recipe.items) do for _,item in pairs(recipe.items) do
if string.sub(item,1,string.len("group:"))=="group:" then if string.find(item, "group:") then
local current_emc = 0 groupname = item:gsub("group:", "")
for _,definition in pairs(minetest.registered_nodes) do for _, groupitem in pairs(registered_items) do
if definition.groups[item] and definition.emc ~= nil then if minetest.get_item_group(groupitem, groupname) == 1 and minetest.registered_items[groupitem].emc then
if definition.emc < current_emc then emcvalue = emcvalue + minetest.registered_items[groupitem].emc
current_emc = definition.emc
elseif current_emc == 0 then
current_emc = definition.emc
end
end end
end end
emcvalue = current_emc
elseif minetest.registered_items[item] and minetest.registered_items[item].emc then elseif minetest.registered_items[item] and minetest.registered_items[item].emc then
emcvalue = emcvalue + minetest.registered_items[item].emc emcvalue = emcvalue + minetest.registered_items[item].emc
else else
@ -143,11 +135,14 @@ for i=1,10 do
emcvalue = emcvalue / craft_number emcvalue = emcvalue / craft_number
end end
end end
print(itemname, emcvalue)
local_emcs[itemname] = emcvalue local_emcs[itemname] = emcvalue
end end
end end
end end
print (local_emcs["default:gold_ingot"])
for item, value in pairs(local_emcs) do for item, value in pairs(local_emcs) do
--print (item,value)
minetest.override_item(item, { minetest.override_item(item, {
description = minetest.registered_items[item].description.."\nEMC Value: "..value, description = minetest.registered_items[item].description.."\nEMC Value: "..value,
emc = value, emc = value,
@ -155,3 +150,6 @@ for i=1,10 do
end end
local_emcs = {} local_emcs = {}
end end