add helper function for {eatable}
This commit is contained in:
parent
71431a298d
commit
191d4acb90
@ -14,7 +14,7 @@ local S = wine.S
|
|||||||
|
|
||||||
-- blue agave
|
-- blue agave
|
||||||
minetest.register_node("wine:blue_agave", {
|
minetest.register_node("wine:blue_agave", {
|
||||||
description = S("Blue Agave") .. " (♥2)",
|
description = S("Blue Agave"),
|
||||||
drawtype = "plantlike",
|
drawtype = "plantlike",
|
||||||
visual_scale = 0.8,
|
visual_scale = 0.8,
|
||||||
tiles = {"wine_blue_agave.png"},
|
tiles = {"wine_blue_agave.png"},
|
||||||
@ -28,7 +28,7 @@ minetest.register_node("wine:blue_agave", {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}
|
fixed = {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}
|
||||||
},
|
},
|
||||||
groups = {snappy = 3, attached_node = 1, plant = 1, eatable = 2},
|
groups = {snappy = 3, attached_node = 1, plant = 1},
|
||||||
sounds = snd_l,
|
sounds = snd_l,
|
||||||
|
|
||||||
on_use = minetest.item_eat(2),
|
on_use = minetest.item_eat(2),
|
||||||
@ -73,6 +73,7 @@ minetest.register_node("wine:blue_agave", {
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
wine.add_eatable("wine:blue_agave", 2)
|
||||||
|
|
||||||
-- blue agave into cyan dye
|
-- blue agave into cyan dye
|
||||||
if minetest.get_modpath("mcl_dye") then
|
if minetest.get_modpath("mcl_dye") then
|
||||||
|
27
init.lua
27
init.lua
@ -69,13 +69,34 @@ function wine:add_item(list)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- helper function
|
||||||
|
|
||||||
|
local mod_tt_base = minetest.get_modpath("tt_base")
|
||||||
|
|
||||||
|
function wine.add_eatable(item, hp)
|
||||||
|
|
||||||
|
local def = minetest.registered_items[item]
|
||||||
|
|
||||||
|
if def then
|
||||||
|
|
||||||
|
local grps = def.groups or {}
|
||||||
|
|
||||||
|
grps.eatable = hp ; grps.flammable = 2
|
||||||
|
|
||||||
|
if mod_tt_base == nil then
|
||||||
|
def.description = def.description .. " (♥" .. hp .. ")"
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.override_item(item, {description = def.description, groups = grps})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- add drink with bottle
|
-- add drink with bottle
|
||||||
function wine:add_drink(name, desc, has_bottle, num_hunger, num_thirst, alcoholic)
|
function wine:add_drink(name, desc, has_bottle, num_hunger, num_thirst, alcoholic)
|
||||||
|
|
||||||
-- glass
|
-- glass
|
||||||
minetest.register_node("wine:glass_" .. name, {
|
minetest.register_node("wine:glass_" .. name, {
|
||||||
description = S("Glass of " .. desc) .. " (♥" .. num_hunger .. ")",
|
description = S("Glass of " .. desc),
|
||||||
drawtype = "plantlike",
|
drawtype = "plantlike",
|
||||||
visual_scale = 0.5,
|
visual_scale = 0.5,
|
||||||
tiles = {"wine_" .. name .. "_glass.png"},
|
tiles = {"wine_" .. name .. "_glass.png"},
|
||||||
@ -90,7 +111,7 @@ function wine:add_drink(name, desc, has_bottle, num_hunger, num_thirst, alcoholi
|
|||||||
fixed = {-0.15, -0.5, -0.15, 0.15, 0, 0.15}
|
fixed = {-0.15, -0.5, -0.15, 0.15, 0, 0.15}
|
||||||
},
|
},
|
||||||
groups = {
|
groups = {
|
||||||
vessel = 1, dig_immediate = 3, eatable = num_hunger,
|
vessel = 1, dig_immediate = 3,
|
||||||
attached_node = 1, drink = 1, alcohol = alcoholic
|
attached_node = 1, drink = 1, alcohol = alcoholic
|
||||||
},
|
},
|
||||||
sounds = snd_g,
|
sounds = snd_g,
|
||||||
@ -109,6 +130,8 @@ function wine:add_drink(name, desc, has_bottle, num_hunger, num_thirst, alcoholi
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
wine.add_eatable("wine:glass_" .. name, num_hunger)
|
||||||
|
|
||||||
-- bottle
|
-- bottle
|
||||||
if has_bottle then
|
if has_bottle then
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user