added level system for potions
This commit is contained in:
parent
4c09d08e46
commit
1f4c345ecf
@ -1,34 +1,36 @@
|
|||||||
potions = {}
|
potions = {}
|
||||||
function potions.register_potion(name, def)
|
function potions.register_potion(name, def)
|
||||||
minetest.register_craftitem(name, {
|
for i = 1, 5 do
|
||||||
description = def.description,
|
minetest.register_craftitem(name .. "_" .. tostring(i), {
|
||||||
inventory_image = def.img,
|
description = def.description .. "\n Level : " .. tostring(i),
|
||||||
|
inventory_image = def.img,
|
||||||
|
|
||||||
on_drop = function(itemstack, dropper, pos)
|
on_drop = function(itemstack, dropper, pos)
|
||||||
if not dropper or not dropper:is_player() then
|
if not dropper or not dropper:is_player() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
return def.on_use(itemstack, dropper)
|
return def.on_use(itemstack, dropper, i)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
if not user or not user:is_player() then
|
if not user or not user:is_player() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
return def.on_use(itemstack, user)
|
return def.on_use(itemstack, user, i)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
potions.register_potion("potions:healing", {
|
potions.register_potion("potions:healing", {
|
||||||
description = "Potion of Healing",
|
description = "Potion of Healing",
|
||||||
img = "potions_red.png",
|
img = "potions_red.png",
|
||||||
on_use = function(itemstack, user)
|
on_use = function(itemstack, user, lvl)
|
||||||
if not user or not user:is_player() then
|
if not user or not user:is_player() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
cmsg.push_message_player(user, "[hp] + 10")
|
cmsg.push_message_player(user, "[hp] + ".. tostring(10+lvl))
|
||||||
user:set_hp(user:get_hp()+10)
|
user:set_hp(user:get_hp()+10+lvl)
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
@ -37,7 +39,7 @@ potions.register_potion("potions:healing", {
|
|||||||
potions.register_potion("potions:jumping", {
|
potions.register_potion("potions:jumping", {
|
||||||
description = "Potion of Jumping",
|
description = "Potion of Jumping",
|
||||||
img = "potions_blue.png",
|
img = "potions_blue.png",
|
||||||
on_use = function(itemstack, user)
|
on_use = function(itemstack, user, lvl)
|
||||||
if not user or not user:is_player() then
|
if not user or not user:is_player() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -46,7 +48,7 @@ potions.register_potion("potions:jumping", {
|
|||||||
})
|
})
|
||||||
cmsg.push_message_player(user, "[effect] + jump")
|
cmsg.push_message_player(user, "[effect] + jump")
|
||||||
|
|
||||||
minetest.after(10.0, function(pl)
|
minetest.after(10.0+lvl*2, function(pl)
|
||||||
if not pl or not pl:is_player() then
|
if not pl or not pl:is_player() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -63,7 +65,7 @@ potions.register_potion("potions:jumping", {
|
|||||||
potions.register_potion("potions:running", {
|
potions.register_potion("potions:running", {
|
||||||
description = "Potion of Running",
|
description = "Potion of Running",
|
||||||
img = "potions_yellow.png",
|
img = "potions_yellow.png",
|
||||||
on_use = function(itemstack, user)
|
on_use = function(itemstack, user, lvl)
|
||||||
if not user or not user:is_player() then
|
if not user or not user:is_player() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -72,7 +74,7 @@ potions.register_potion("potions:running", {
|
|||||||
})
|
})
|
||||||
cmsg.push_message_player(user, "[effect] + speed")
|
cmsg.push_message_player(user, "[effect] + speed")
|
||||||
|
|
||||||
minetest.after(10.0, function(pl)
|
minetest.after(10.0+lvl*2, function(pl)
|
||||||
if not pl or not pl:is_player() then
|
if not pl or not pl:is_player() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user