2016-05-14 04:12:48 +02:00
|
|
|
-- trampoline nodebox
|
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},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-14 04:12:48 +02:00
|
|
|
-- cushion nodebox
|
2012-09-05 10:35:50 +02:00
|
|
|
local cushionbox = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5, -0.5, -0.5, 0.5, -0.3, 0.5},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-14 04:12:48 +02:00
|
|
|
-- left click: update trampoline to increase power level
|
2012-09-05 17:46:33 +02:00
|
|
|
local trampoline_punch = function(pos, node)
|
2016-05-14 04:12:48 +02:00
|
|
|
local id = string.sub(node.name, #node.name) -- get node "id"
|
|
|
|
local meta = minetest.get_meta(pos) -- get meta access
|
2016-05-14 03:55:57 +02:00
|
|
|
if id < "6" then
|
2016-05-14 04:12:48 +02:00
|
|
|
id = id + 1 -- set id one value higher
|
|
|
|
minetest.add_node(pos, {name = string.sub(node.name, 1, #node.name - 1)..id}) -- update trampoline node
|
|
|
|
meta:set_string("infotext", "Power Level: "..id) -- set infotext
|
2016-05-14 03:55:57 +02:00
|
|
|
end
|
2012-09-05 17:46:33 +02:00
|
|
|
end
|
|
|
|
|
2016-05-14 04:12:48 +02:00
|
|
|
-- right click: update trampoline to decrease power level
|
|
|
|
local power_decrease = function(pos, node)
|
|
|
|
local id = string.sub(node.name, #node.name) -- get node "id"
|
|
|
|
local meta = minetest.get_meta(pos) -- get meta access
|
|
|
|
id = id - 1 -- set id one value lower
|
|
|
|
minetest.add_node(pos, {name = string.sub(node.name, 1, #node.name - 1)..id}) -- update trampoline node
|
|
|
|
meta:set_string("infotext", "Power Level: "..id) -- set infotext
|
|
|
|
end
|
|
|
|
|
|
|
|
-- register trampolines of power level 2-6
|
2016-05-14 03:55:57 +02:00
|
|
|
for i = 2, 6 do
|
2012-09-05 17:46:33 +02:00
|
|
|
minetest.register_node("jumping:trampoline"..i, {
|
|
|
|
description = "Trampoline",
|
|
|
|
drawtype = "nodebox",
|
|
|
|
node_box = trampolinebox,
|
|
|
|
selection_box = trampolinebox,
|
|
|
|
paramtype = "light",
|
2016-05-14 04:12:48 +02:00
|
|
|
on_punch = trampoline_punch, -- on punch (left click) increase poser lever
|
|
|
|
on_rightclick = power_decrease,
|
|
|
|
on_construct = function(pos) -- set meta data on place
|
2016-05-14 03:55:57 +02:00
|
|
|
local meta = minetest.get_meta(pos)
|
2016-05-14 04:12:48 +02:00
|
|
|
meta:set_string("infotext", "Power Level: "..i)
|
2016-05-14 03:55:57 +02:00
|
|
|
end,
|
|
|
|
drop = "jumping:trampoline1",
|
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"
|
|
|
|
},
|
2016-05-14 03:55:57 +02:00
|
|
|
groups = {dig_immediate=2, bouncy=20+i*20, fall_damage_add_percent=-70, not_in_creative_inventory=1},
|
2012-09-05 17:46:33 +02:00
|
|
|
})
|
|
|
|
end
|
2012-09-05 10:35:50 +02:00
|
|
|
|
2016-05-14 04:12:48 +02:00
|
|
|
-- register trampoline power level 1
|
2016-05-14 03:55:57 +02:00
|
|
|
minetest.register_node("jumping:trampoline1", {
|
|
|
|
description = "Trampoline",
|
|
|
|
drawtype = "nodebox",
|
|
|
|
node_box = trampolinebox,
|
|
|
|
selection_box = trampolinebox,
|
|
|
|
paramtype = "light",
|
|
|
|
on_punch = trampoline_punch,
|
2016-05-14 04:12:48 +02:00
|
|
|
on_construct = function(pos) -- set meta data on place
|
2016-05-14 03:55:57 +02:00
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
meta:set_string("infotext", "Power Level: 1")
|
|
|
|
end,
|
|
|
|
tiles = {
|
|
|
|
"jumping_trampoline_top.png",
|
|
|
|
"jumping_trampoline_bottom.png",
|
|
|
|
"jumping_trampoline_sides.png^jumping_trampoline_sides_overlay1.png"
|
|
|
|
},
|
|
|
|
groups = {dig_immediate=2, bouncy=20+1*20, fall_damage_add_percent=-70},
|
|
|
|
})
|
|
|
|
|
2016-05-14 04:12:48 +02:00
|
|
|
-- register cushion
|
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",
|
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
|
|
|
|
2016-05-14 04:12:48 +02:00
|
|
|
-- register recipe for trampoline (power lever 1)
|
2012-09-24 16:15:14 +02:00
|
|
|
minetest.register_craft({
|
|
|
|
output = "jumping:trampoline1",
|
|
|
|
recipe = {
|
2016-05-14 03:55:57 +02:00
|
|
|
{"group:wood", "group:wood", "group:wood"},
|
|
|
|
{"group:leaves", "group:leaves", "group:leaves"},
|
2012-09-24 16:15:14 +02:00
|
|
|
{"default:stick", "default:stick", "default:stick"}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2016-05-14 04:12:48 +02:00
|
|
|
-- register recipe for cushion
|
2012-09-24 16:15:14 +02:00
|
|
|
minetest.register_craft({
|
|
|
|
output = "jumping:cushion",
|
|
|
|
recipe = {
|
|
|
|
{"default:leaves", "default:leaves", "default:leaves"},
|
|
|
|
{"default:leaves", "default:leaves", "default:leaves"},
|
|
|
|
{"default:stick", "default:stick", "default:stick"}
|
|
|
|
}
|
|
|
|
})
|