144 lines
3.3 KiB
Lua
Raw Normal View History

2016-02-05 12:48:46 +01:00
potions = {}
function potions.register_potion(name, def)
minetest.register_craftitem(name, {
description = def.description,
inventory_image = def.img,
2015-12-31 11:01:14 +01:00
on_drop = function(itemstack, dropper, pos)
if not dropper or not dropper:is_player() then
return
end
2016-02-05 12:48:46 +01:00
return def.on_use(itemstack, dropper)
2015-12-31 11:01:14 +01:00
end,
on_use = function(itemstack, user, pointed_thing)
if not user or not user:is_player() then
return
end
2016-02-05 12:48:46 +01:00
return def.on_use(itemstack, user)
2015-12-31 11:01:14 +01:00
end,
})
2016-02-05 12:48:46 +01:00
end
2015-12-31 11:01:14 +01:00
2016-02-05 12:48:46 +01:00
potions.register_potion("potions:healing", {
description = "Potion of Healing",
img = "potions_red.png",
on_use = function(itemstack, user)
if not user or not user:is_player() then
2015-12-31 11:01:14 +01:00
return
end
2016-02-05 12:48:46 +01:00
cmsg.push_message_player(user, "[hp] + 10")
user:set_hp(user:get_hp()+10)
2015-12-31 11:01:14 +01:00
itemstack:take_item()
return itemstack
2016-02-05 12:48:46 +01:00
end
})
2015-12-31 11:01:14 +01:00
2016-02-05 12:48:46 +01:00
potions.register_potion("potions:jumping", {
description = "Potion of Jumping",
img = "potions_blue.png",
on_use = function(itemstack, user)
2015-12-31 11:01:14 +01:00
if not user or not user:is_player() then
return
end
user:set_physics_override({
gravity = 0.1,
})
cmsg.push_message_player(user, "[effect] + jump")
2015-12-31 11:01:14 +01:00
minetest.after(10.0, function(pl)
if not pl or not pl:is_player() then
return
end
pl:set_physics_override({
gravity = 1,
})
cmsg.push_message_player(pl, "[effect] - jump")
2015-12-31 11:01:14 +01:00
end, user)
itemstack:take_item()
return itemstack
2016-02-05 12:48:46 +01:00
end
2015-12-31 11:01:14 +01:00
})
2016-02-05 12:48:46 +01:00
potions.register_potion("potions:running", {
2015-12-31 11:01:14 +01:00
description = "Potion of Running",
2016-02-05 12:48:46 +01:00
img = "potions_yellow.png",
on_use = function(itemstack, user)
2015-12-31 11:01:14 +01:00
if not user or not user:is_player() then
return
end
user:set_physics_override({
speed = 3,
})
cmsg.push_message_player(user, "[effect] + speed")
2015-12-31 11:01:14 +01:00
minetest.after(10.0, function(pl)
if not pl or not pl:is_player() then
return
end
pl:set_physics_override({
speed = 1,
})
cmsg.push_message_player(pl, "[effect] - speed")
2015-12-31 11:01:14 +01:00
end, user)
itemstack:take_item()
return itemstack
2016-02-05 12:48:46 +01:00
end
})
minetest.register_craftitem("potions:strange", {
description = "strange Potion",
inventory_image = "potions_black.png",
})
minetest.register_craftitem("potions:glass", {
description = "Glass",
inventory_image = "potions_glass.png",
2015-12-31 11:01:14 +01:00
})
2016-01-03 12:08:51 +01:00
minetest.register_craftitem("potions:upgrading", {
description = "Potion of Upgrading",
inventory_image = "potions_green.png",
})
2016-02-05 12:48:46 +01:00
-- crafting
minetest.register_craft({
type = "shapeless",
output = "potions:strange",
recipe = {"potions:glass", "juice:cactus", "juice:cactus", "juice:water"},
replacements = {
{"juice:cactus", "juice:glass"},
{"juice:cactus", "juice:glass"},
{"juice:water", "juice:glass"}
}
})
minetest.register_craft({
type = "shapeless",
output = "potions:running",
recipe = {"juice:water_sugar", "juice:water_sugar", "juice:water_sugar", "potions:glass"},
replacements = {
{"juice:water_sugar", "juice:glass"},
{"juice:water_sugar", "juice:glass"},
{"juice:water_sugar", "juice:glass"}
}
})
minetest.register_craft({
type = "shapeless",
output = "potions:jumping",
recipe = {"juice:water_sugar", "juice:water_sugar", "juice:water", "potions:glass"},
replacements = {
{"juice:water_sugar", "juice:glass"},
{"juice:water_sugar", "juice:glass"},
{"juice:water", "juice:glass"}
}
})
minetest.register_craft({
type = "shapeless",
output = "potions:upgrading",
recipe = {"potions:strange", "default:stone_item", "farming:cactus", "default:sand"},
})