Compare commits

..

No commits in common. "master" and "0.1.4" have entirely different histories.

3 changed files with 102 additions and 110 deletions

5
depends.txt Normal file
View File

@ -0,0 +1,5 @@
mcl_core
mcl_mushrooms
mcl_flowers
mcl_potions
mcl_hunger

204
init.lua
View File

@ -4,139 +4,129 @@
local eat = minetest.item_eat(6, "mcl_core:bowl") --6 hunger points, player receives mcl_core:bowl after eating local eat = minetest.item_eat(6, "mcl_core:bowl") --6 hunger points, player receives mcl_core:bowl after eating
local flower_effect = {
[ "mcl_flowers:allium" ] = "fire_resistance",
[ "mcl_flowers:tulip_white" ] = "poison",
[ "mcl_flowers:blue_orchid" ] = "hunger",
[ "mcl_flowers:dandelion" ] = "hunger",
[ "mcl_flowers:peony" ] = "jump",
[ "mcl_flowers:oxeye_daisy" ] = "regeneration",
[ "mcl_flowers:poppy" ] = "night_vision"
}
local effects = {
[ "fire_resistance" ] = function(itemstack, placer, pointed_thing)
mcl_potions.fire_resistance_func(placer, 1, 4)
return eat(itemstack, placer, pointed_thing)
end,
[ "poison" ] = function(itemstack, placer, pointed_thing)
mcl_potions.poison_func(placer, 1, 12)
return eat(itemstack, placer, pointed_thing)
end,
[ "hunger" ] = function(itemstack, placer, pointed_thing, player) local function poison(itemstack, placer, pointed_thing)
mcl_hunger.item_eat(6, "mcl_core:bowl", 3.5, 0, 100) local hunger = mcl_hunger.get_hunger(placer)
return eat(itemstack, placer, pointed_thing) if hunger < 20 then
end, mcl_potions.poison_func(placer, 1, 12)
return eat(itemstack, placer, pointed_thing)
["jump"] = function(itemstack, placer, pointed_thing) end
mcl_potions.leaping_func(placer, 1, 6)
return eat(itemstack, placer, pointed_thing)
end,
["regeneration"] = function(itemstack, placer, pointed_thing)
mcl_potions.regeneration_func(placer, 1, 8)
return eat(itemstack, placer, pointed_thing)
end,
["night_vision"] = function(itemstack, placer, pointed_thing)
mcl_potions.night_vision_func(placer, 1, 5)
return eat(itemstack, placer, pointed_thing)
end,
}
local function get_random_effect()
local keys = {}
for k in pairs(effects) do
table.insert(keys, k)
end
return effects[keys[math.random(#keys)]]
end end
local function eat_stew(itemstack, placer, pointed_thing) local function hunger(itemstack, placer, pointed_thing, player)
local e = itemstack:get_meta():get_string("effect") local hunger = mcl_hunger.get_hunger(placer)
local f = effects[e] if hunger < 20 then
if not f then return eat(itemstack, placer, pointed_thing)
f = get_random_effect() end
end
if f(itemstack,placer,pointed_thing) then
return "mcl_core:bowl"
end
end end
minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) local function jump_boost(itemstack, placer, pointed_thing)
if itemstack:get_name() ~= "mcl_sus_stew:stew" then return end local hunger = mcl_hunger.get_hunger(placer)
for f,e in pairs(flower_effect) do if hunger < 20 then
for _,it in pairs(old_craft_grid) do mcl_potions.leaping_func(placer, 1, 6)
if it:get_name() == f then return eat(itemstack, placer, pointed_thing)
itemstack:get_meta():set_string("effect",e) end
return itemstack end
end
end
end
end)
-- ________________________ local function regeneration(itemstack, placer, pointed_thing)
--_________________________________________/ Item Regestration \_________________ local hunger = mcl_hunger.get_hunger(placer)
minetest.register_craftitem("mcl_sus_stew:stew",{ if hunger < 20 then
description = "Suspicious Stew", mcl_potions.regeneration_func(placer, 1, 8)
inventory_image = "sus_stew.png", return eat(itemstack, placer, pointed_thing)
stack_max = 1, end
on_place = eat_stew, end
on_secondary_use = eat_stew,
groups = { food = 2, eatable = 4, can_eat_when_full = 1, not_in_creative_inventory=1,}, local function night_vision(itemstack, placer, pointed_thing)
_mcl_saturation = 7.2, local hunger = mcl_hunger.get_hunger(placer)
if hunger < 20 then
mcl_potions.night_vision_func(placer, 1, 5)
return eat(itemstack, placer, pointed_thing)
end
end
-- ________________________
--_________________________________________/ Item Regestration \_________________
minetest.register_craftitem("mcl_sus_stew:poison_stew",{
description = "Suspicious Stew",
inventory_image = "sus_stew.png",
stack_max = 1,
on_place = poison,
groups = { food = 2, eatable = 4, not_in_creative_inventory=1,},
_mcl_saturation = 7.2,
}) })
mcl_hunger.register_food("mcl_sus_stew:stew",6, "mcl_core:bowl") minetest.register_craftitem("mcl_sus_stew:hunger_stew",{
description = "Suspicious Stew",
inventory_image = "sus_stew.png",
stack_max = 1,
on_place = hunger,
groups = { food = 2, eatable = 4, not_in_creative_inventory=1,},
_mcl_saturation = 7.2,
})
--compat with old (mcl5) sus_stew minetest.register_craftitem("mcl_sus_stew:jump_boost_stew",{
minetest.register_alias("mcl_sus_stew:poison_stew", "mcl_sus_stew:stew") description = "Suspicious Stew",
minetest.register_alias("mcl_sus_stew:hunger_stew", "mcl_sus_stew:stew") inventory_image = "sus_stew.png",
minetest.register_alias("mcl_sus_stew:jump_boost_stew", "mcl_sus_stew:stew") stack_max = 1,
minetest.register_alias("mcl_sus_stew:regneration_stew", "mcl_sus_stew:stew") on_place = jump_boost,
minetest.register_alias("mcl_sus_stew:night_vision_stew", "mcl_sus_stew:stew") groups = { food = 2, eatable = 4, not_in_creative_inventory=1,},
_mcl_saturation = 7.2,
})
-- ______________ minetest.register_craftitem("mcl_sus_stew:regneration_stew",{
--_________________________________________/ Crafts \________________________________ description = "Suspicious Stew",
inventory_image = "sus_stew.png",
stack_max = 1,
on_place = regeneration,
groups = { food = 2, eatable = 4, not_in_creative_inventory=1,},
_mcl_saturation = 7.2,
})
minetest.register_craftitem("mcl_sus_stew:night_vision_stew",{
description = "Suspicious Stew",
inventory_image = "sus_stew.png",
stack_max = 1,
on_place = night_vision,
groups = { food = 2, eatable = 4, not_in_creative_inventory=1,},
_mcl_saturation = 7.2,
})
-- ____________________________
--______________________________________/ Using mcl_hunger API \______________________
mcl_hunger.register_food("mcl_sus_stew:hunger_stew",6, "mcl_core:bowl", 3.5, 0, 100) -- Register it using mcl_hunger so i can use its poison feature
-- ______________
--_________________________________________/ Crafts \________________________________
minetest.register_craft({ minetest.register_craft({
type = "shapeless", output = "mcl_sus_stew:poison_stew",
output = "mcl_sus_stew:stew", recipe = { {"mcl_mushrooms:mushroom_red", "mcl_mushrooms:mushroom_brown"}, {"mcl_core:bowl", "mcl_flowers:tulip_white"} },
recipe = {"mcl_mushrooms:mushroom_red", "mcl_mushrooms:mushroom_brown", "mcl_core:bowl", "mcl_flowers:allium"},
}) })
minetest.register_craft({ minetest.register_craft({
type = "shapeless", output = "mcl_sus_stew:hunger_stew",
output = "mcl_sus_stew:stew", recipe = { {"mcl_mushrooms:mushroom_red", "mcl_mushrooms:mushroom_brown"}, {"mcl_core:bowl", "mcl_flowers:blue_orchid"} },
recipe = {"mcl_mushrooms:mushroom_red", "mcl_mushrooms:mushroom_brown", "mcl_core:bowl", "mcl_flowers:tulip_white"},
}) })
minetest.register_craft({ minetest.register_craft({
type = "shapeless", output = "mcl_sus_stew:hunger_stew",
output = "mcl_sus_stew:stew", recipe = { {"mcl_mushrooms:mushroom_red", "mcl_mushrooms:mushroom_brown"}, {"mcl_core:bowl", "mcl_flowers:dandelion"} },
recipe = {"mcl_mushrooms:mushroom_red", "mcl_mushrooms:mushroom_brown", "mcl_core:bowl", "mcl_flowers:blue_orchid"},
}) })
minetest.register_craft({ minetest.register_craft({
type = "shapeless", output = "mcl_sus_stew:jump_boost_stew",
output = "mcl_sus_stew:stew", recipe = { {"mcl_mushrooms:mushroom_red", "mcl_mushrooms:mushroom_brown"}, {"mcl_core:bowl", "mcl_flowers:peony"} },
recipe = {"mcl_mushrooms:mushroom_red", "mcl_mushrooms:mushroom_brown", "mcl_core:bowl", "mcl_flowers:dandelion"} ,
}) })
minetest.register_craft({ minetest.register_craft({
type = "shapeless", output = "mcl_sus_stew:regeneration_stew",
output = "mcl_sus_stew:stew", recipe = { {"mcl_mushrooms:mushroom_red", "mcl_mushrooms:mushroom_brown"}, {"mcl_core:bowl", "mcl_flowers:oxeye_daisy"} },
recipe = {"mcl_mushrooms:mushroom_red", "mcl_mushrooms:mushroom_brown", "mcl_core:bowl", "mcl_flowers:peony"},
}) })
minetest.register_craft({ minetest.register_craft({
type = "shapeless", output = "mcl_sus_stew:night_vision_stew",
output = "mcl_sus_stew:stew", recipe = { {"mcl_mushrooms:mushroom_red", "mcl_mushrooms:mushroom_brown"}, {"mcl_core:bowl", "mcl_flowers:poppy"} },
recipe = {"mcl_mushrooms:mushroom_red", "mcl_mushrooms:mushroom_brown", "mcl_core:bowl", "mcl_flowers:oxeye_daisy"},
})
minetest.register_craft({
type = "shapeless",
output = "mcl_sus_stew:stew",
recipe = {"mcl_mushrooms:mushroom_red", "mcl_mushrooms:mushroom_brown", "mcl_core:bowl", "mcl_flowers:poppy"},
}) })

View File

@ -1,3 +0,0 @@
name = mcl_sus_stew
author = chmodsayshello, cora
depends = mcl_core, mcl_mushrooms, mcl_flowers, mcl_potions, mcl_hunger