added diamond apples

master
juraj 2016-03-12 15:00:45 +01:00
parent 07d0249dd5
commit 8a060094c5
7 changed files with 77 additions and 13 deletions

View File

@ -1 +1,2 @@
default
default
playereffects?

View File

@ -1,11 +1,12 @@
--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
--Diamonds by InfinityProject +
-- +
--LICENSE: WTFPL DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE; applies to all parts. +
-- +
--Please give any ideas on ways to improve this mod! +
--Diamonds by InfinityProject - re-done by SaKeL
--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
local apple_duration = 16.0 --seconds
local apple_buff_speed = 1 --add to physics multiplier
local apple_buff_jump = 0.5 --add to physics multiplier
local apple_buff_gravity = 0.1 --subtract from physics multiplier
minetest.register_node( "diamonds:diamond_in_ground", {
description = "Super Diamond Ore",
tiles = { "default_stone.png^diamond_in_ground.png" },
@ -28,6 +29,62 @@ minetest.register_craftitem( "diamonds:diamond", {
on_place_on_ground = minetest.craftitem_place_item,
})
if minetest.get_modpath("playereffects") ~= nil then
-- playereffects.register_effect_type(effect_type_id, description, icon, groups, apply, cancel, hidden, cancel_on_death, repeat_interval)
playereffects.register_effect_type("diamonds:apple_eff", "Apple Powers", "diamond_apple_16.png", {"apple_eff"},
function(player)
player:set_physics_override(2,1.5,1.1)
end,
function(effect, player)
player:set_physics_override(1,1,1)
end,
false, true
)
playereffects.register_effect_type("diamonds:apple_eff_regen", "Health Regen", "heart_16.png", {"health"},
function(player)
player:set_hp(player:get_hp()+2)
end,
nil, false, true, 1
)
end
minetest.register_craftitem("diamonds:diamond_apple", {
description = "Super diamond apple.",
inventory_image = "diamond_apple.png",
on_use = function(itemstack, user, pointed_thing)
minetest.sound_play("apple_eat", {to_player = user:get_player_name(), gain = 0.7})
user:set_hp(20)
if minetest.get_modpath("playereffects") ~= nil then
local effects = playereffects.get_player_effects(user:get_player_name())
-- if #effects > 0 then
-- for e=1, #effects do
-- if effects[e].effect_type_id == "diamonds:apple_eff" then
-- minetest.chat_send_player(user:get_player_name(), "You can eat only one diamond apple at one time.")
-- return
-- end
-- end
-- end
-- playereffects.apply_effect_type(effect_type_id, duration, player, repeat_interval_time_left)
playereffects.apply_effect_type("diamonds:apple_eff", 30, user)
playereffects.apply_effect_type("diamonds:apple_eff_regen", 30, user)
minetest.chat_send_player(user:get_player_name(), "You have super powers for 30 seconds.")
end
itemstack:take_item()
return itemstack
end
})
--
--Tools
--
@ -173,9 +230,6 @@ minetest.register_tool("diamonds:steelpick", {
--
--Diamond Showcase
--
--This is still registered as diamonds:garden. I will change it and probably add an abm to replace
--all old blocks soon.
--
minetest.register_node( "diamonds:garden_block", {
description = "Super Diamond Showcase",
@ -202,7 +256,7 @@ function add_garden(pos, node, active_object_count, active_object_count_wider)
node.name == "diamonds:garden_block"
then
pos.y = pos.y + 1
minetest.env:add_node(pos, {name="diamonds:garden"})
minetest.add_node(pos, {name="diamonds:garden"})
end
end
minetest.register_on_placenode(add_garden)
@ -212,7 +266,7 @@ function remove_garden(pos, node, active_object_count, active_object_count_wider
node.name == "diamonds:garden_block"
then
pos.y = pos.y + 1
minetest.env:remove_node(pos, {name="diamonds:garden"})
minetest.remove_node(pos, {name="diamonds:garden"})
end
end
minetest.register_on_dignode(remove_garden)
@ -361,6 +415,15 @@ minetest.register_craft({
}
})
minetest.register_craft({
output = 'diamonds:diamond_apple 2',
recipe = {
{'diamonds:diamond', 'diamonds:diamond', 'diamonds:diamond'},
{'diamonds:diamond','default:apple', 'diamonds:diamond'},
{'diamonds:diamond', 'diamonds:diamond', 'diamonds:diamond'},
}
})
--
--Generation
--
@ -394,8 +457,8 @@ local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume,
local y2 = y0+y1
local z2 = z0+z1
local p2 = {x=x2, y=y2, z=z2}
if minetest.env:get_node(p2).name == wherein then
minetest.env:set_node(p2, {name=name})
if minetest.get_node(p2).name == wherein then
minetest.set_node(p2, {name=name})
end
end
end

BIN
sounds/apple_eat.1.ogg Normal file

Binary file not shown.

BIN
sounds/apple_eat.2.ogg Normal file

Binary file not shown.

BIN
textures/diamond_apple.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 385 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

BIN
textures/heart_16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B