2012-09-05 10:35:50 +02:00
|
|
|
local trampolinebox = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5, -0.2, -0.5, 0.5, 0, 0.5},
|
|
|
|
|
|
|
|
{-0.5, -0.5, -0.5, -0.4, -0.2, -0.4},
|
|
|
|
{ 0.4, -0.5, -0.5, 0.5, -0.2, -0.4},
|
|
|
|
{ 0.4, -0.5, 0.4, 0.5, -0.2, 0.5},
|
|
|
|
{-0.5, -0.5, 0.4, -0.4, -0.2, 0.5},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
local cushionbox = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5, -0.5, -0.5, 0.5, -0.3, 0.5},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-05 17:46:33 +02:00
|
|
|
local trampoline_punch = function(pos, node)
|
|
|
|
local id = string.sub(node.name, #node.name)
|
2018-04-23 20:10:19 +02:00
|
|
|
if id < "6" then
|
|
|
|
id = id + 1
|
2018-04-23 20:27:03 +02:00
|
|
|
minetest.swap_node(pos, {name = string.sub(node.name, 1, #node.name - 1)..id})
|
2018-04-23 20:10:19 +02:00
|
|
|
minetest.get_meta(pos):set_string("infotext", "Bouncy Level: "..id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local power_decrease = function(pos, node)
|
|
|
|
local id = string.sub(node.name, #node.name)
|
|
|
|
if id > "1" then
|
|
|
|
id = id - 1
|
2018-04-23 20:27:03 +02:00
|
|
|
minetest.swap_node(pos, {name = string.sub(node.name, 1, #node.name - 1)..id})
|
2018-04-23 20:10:19 +02:00
|
|
|
minetest.get_meta(pos):set_string("infotext", "Bouncy Level: "..id)
|
|
|
|
end
|
2012-09-05 17:46:33 +02:00
|
|
|
end
|
|
|
|
|
2022-06-26 17:57:40 +02:00
|
|
|
local use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or nil
|
2012-09-05 17:46:33 +02:00
|
|
|
for i = 1, 6 do
|
|
|
|
minetest.register_node("jumping:trampoline"..i, {
|
|
|
|
description = "Trampoline",
|
|
|
|
drawtype = "nodebox",
|
|
|
|
node_box = trampolinebox,
|
|
|
|
selection_box = trampolinebox,
|
|
|
|
paramtype = "light",
|
2018-04-21 13:59:32 +02:00
|
|
|
on_construct = function(pos)
|
|
|
|
minetest.get_meta(pos):set_string("infotext", "Bouncy Level: "..i)
|
|
|
|
end,
|
2012-09-05 17:46:33 +02:00
|
|
|
on_punch = trampoline_punch,
|
2018-04-23 20:10:19 +02:00
|
|
|
on_rightclick = power_decrease,
|
2018-04-23 20:20:55 +02:00
|
|
|
drop = "jumping:trampoline1",
|
2022-06-26 17:57:40 +02:00
|
|
|
use_texture_alpha = use_texture_alpha,
|
2012-09-05 17:46:33 +02:00
|
|
|
tiles = {
|
|
|
|
"jumping_trampoline_top.png",
|
|
|
|
"jumping_trampoline_bottom.png",
|
|
|
|
"jumping_trampoline_sides.png^jumping_trampoline_sides_overlay"..i..".png"
|
|
|
|
},
|
2018-04-23 20:20:55 +02:00
|
|
|
groups = {
|
|
|
|
dig_immediate = 2,
|
|
|
|
bouncy = 20 + i * 20,
|
|
|
|
fall_damage_add_percent = -70,
|
|
|
|
not_in_creative_inventory = ( i > 1 and 1 or nil),
|
|
|
|
},
|
2012-09-05 17:46:33 +02:00
|
|
|
})
|
|
|
|
end
|
2012-09-05 10:35:50 +02:00
|
|
|
|
|
|
|
minetest.register_node("jumping:cushion", {
|
|
|
|
description = "Cushion",
|
|
|
|
drawtype = "nodebox",
|
|
|
|
node_box = cushionbox,
|
|
|
|
selection_box = cushionbox,
|
|
|
|
paramtype = "light",
|
2022-06-26 17:57:40 +02:00
|
|
|
use_texture_alpha = use_texture_alpha,
|
2012-09-05 14:12:25 +02:00
|
|
|
tiles = {
|
|
|
|
"jumping_cushion_tb.png",
|
|
|
|
"jumping_cushion_tb.png",
|
|
|
|
"jumping_cushion_sides.png"
|
|
|
|
},
|
2012-09-05 10:35:50 +02:00
|
|
|
groups = {dig_immediate=2, disable_jump=1, fall_damage_add_percent=-100},
|
|
|
|
})
|
2012-09-24 16:15:14 +02:00
|
|
|
|
2021-11-02 19:45:07 +01:00
|
|
|
-- register recipes if the corresponding mods are present
|
|
|
|
if minetest.get_modpath("default") then
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "jumping:trampoline1",
|
|
|
|
recipe = {
|
|
|
|
{"jumping:cushion", "jumping:cushion", "jumping:cushion"},
|
|
|
|
{"default:steel_ingot", "", "default:steel_ingot"}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
end
|
2012-09-24 16:15:14 +02:00
|
|
|
|
2021-11-02 19:45:07 +01:00
|
|
|
if minetest.get_modpath("farming") and minetest.get_modpath("wool") then
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "jumping:cushion",
|
|
|
|
recipe = {
|
|
|
|
{"farming:cotton", "group:wool", "farming:cotton"},
|
|
|
|
{"farming:cotton", "group:wool", "farming:cotton"},
|
|
|
|
{"farming:cotton", "farming:cotton", "farming:cotton"}
|
|
|
|
}
|
|
|
|
})
|
2022-06-26 17:57:40 +02:00
|
|
|
end
|