craft emc work except for groups

This commit is contained in:
yamanq 2015-08-08 12:51:21 -04:00
parent 8caab933f6
commit dd3f8dfff0

@ -41,7 +41,10 @@ local emcs = {
mese_crystal = 425,
-- Precise Value: 848
diamond = 976,
obsidian =
-- REDO VALUE HERE
obsidian = 0,
nyancat = 3786750,
nyancat_rainbow = 3786750,
-- Exceptions --
@ -51,8 +54,10 @@ local emcs = {
stick = 1,
},
["bucket"] = {
bucket_water = 275,
bucket_lava =
bucket_water = 275,
-- REDO VALUE HERE
bucket_lava = 0,
},
["farming"] = {
seed_wheat = 20,
@ -71,12 +76,82 @@ local emcs = {
viola = 5,
},
}
-- Add all items to a table.
local registered_items = {}
local local_emcs = {}
for itemname, value in pairs(minetest.registered_items) do
table.insert(registered_items, itemname)
end
-- Add EMC values to raw materials.
for modname, itemlist in pairs(emcs) do
for itemname, emcvalue in pairs(itemlist) do
minetest.override_item(modname..":"..itemname, {
description = minetest.registered_items[modname..":"..itemname].description.."\nEMC Value: "..emcvalue,
emc = emcvalue,
for itemname, emcvalue in pairs(itemlist) do
minetest.override_item(modname..":"..itemname, {
description = minetest.registered_items[modname..":"..itemname].description.."\nEMC Value: "..emcvalue,
emc = emcvalue,
})
end
end
for i=1,10 do
for _, itemname in pairs(registered_items) do
if itemname ~= ""
and itemname ~= ":"
and minetest.get_all_craft_recipes(itemname) ~= nil
and minetest.registered_items[itemname]
and minetest.registered_items[itemname].emc == nil then
for _, recipe in pairs(minetest.get_all_craft_recipes(itemname)) do
local emcvalue = 0
if recipe.type == "cooking" and minetest.registered_items[recipe.items[1].emc] ~= nil then
emcvalue = minetest.registered_items[recipe.items[1]].emc * 1.5
-- table.insert(exceptions, itemname)
else
for _,item in pairs(recipe.items) do
if string.sub(item,1,string.len("group:"))=="group:" then
local current_emc = 0
for _,definition in pairs(minetest.registered_nodes) do
if definition.groups[item] and definition.emc ~= nil then
if definition.emc < current_emc then
current_emc = definition.emc
elseif current_emc == 0 then
current_emc = definition.emc
end
end
end
emcvalue = current_emc
elseif minetest.registered_items[item] and minetest.registered_items[item].emc then
emcvalue = emcvalue + minetest.registered_items[item].emc
else
emcvalue = nil
break
end
end
output_number = recipe.output:split(" ")
local craft_number
if output_number[2] then
craft_number = tonumber(output_number[2])
else
craft_number = 1
end
if emcvalue ~= nil then
emcvalue = emcvalue / craft_number
end
end
local_emcs[itemname] = emcvalue
end
end
end
for item, value in pairs(local_emcs) do
minetest.override_item(item, {
description = minetest.registered_items[item].description.."\nEMC Value: "..value,
emc = value,
})
end
end
local_emcs = {}
end