63 lines
1.5 KiB
Lua
63 lines
1.5 KiB
Lua
local registered_plant_items = {}
|
|
mcl_vegan.registered_plant_items = registered_plant_items
|
|
|
|
function mcl_vegan.register_plant_items (own_mod_name, base_name, def)
|
|
def.own_mod_name = own_mod_name
|
|
def.base_name = base_name
|
|
|
|
local full_base_name = own_mod_name .. ":" .. base_name
|
|
|
|
registered_plant_items[full_base_name] = def
|
|
|
|
local seed = def.seed
|
|
local full_seed = own_mod_name .. ":" .. seed
|
|
local descriptions = def.descriptions
|
|
-- 0 means inedible
|
|
if def.food_strength == nil then def.food_strength = 0 end
|
|
local food_strength = def.food_strength
|
|
|
|
|
|
|
|
local on_secondary_use = nil
|
|
if food_strength > 0 then
|
|
on_secondary_use = minetest.item_eat(food_strength)
|
|
end
|
|
|
|
local plant_seed = function (item_stack, placer, pointed_thing)
|
|
return mcl_farming:place_seed(item_stack, placer, pointed_thing, full_base_name .. "_1")
|
|
end
|
|
|
|
local on_place = nil
|
|
if seed == base_name then
|
|
on_place = plant_seed
|
|
elseif food_strength > 0 then
|
|
on_place = on_secondary_use
|
|
end
|
|
|
|
|
|
|
|
minetest.register_craftitem(full_base_name, {
|
|
description = descriptions.base,
|
|
groups = {
|
|
craftitem = 1,
|
|
food = 1,
|
|
eatable = food_strength,
|
|
},
|
|
_mcl_saturation = food_strength,
|
|
inventory_image = own_mod_name .. "_" .. base_name .. ".png",
|
|
on_place = on_place,
|
|
on_secondary_use = on_secondary_use
|
|
})
|
|
|
|
if seed ~= base_name then
|
|
minetest.register_craftitem(full_seed, {
|
|
description = descriptions.seed,
|
|
groups = {
|
|
craftitem = 1,
|
|
},
|
|
inventory_image = own_mod_name .. "_" .. seed .. ".png",
|
|
on_place = plant_seed,
|
|
})
|
|
end
|
|
end
|