increade by punch, decrease by rightclick

This commit is contained in:
Alexander Weber 2018-04-23 20:10:19 +02:00 committed by sofar
parent ea83c64fee
commit c7223539f6

@ -19,11 +19,21 @@ local cushionbox = {
local trampoline_punch = function(pos, node) local trampoline_punch = function(pos, node)
local id = string.sub(node.name, #node.name) local id = string.sub(node.name, #node.name)
if id < "6" then
id = id + 1 id = id + 1
if id == 7 then id = 1 end
minetest.add_node(pos, {name = string.sub(node.name, 1, #node.name - 1)..id}) minetest.add_node(pos, {name = string.sub(node.name, 1, #node.name - 1)..id})
minetest.get_meta(pos):set_string("infotext", "Bouncy Level: "..id) minetest.get_meta(pos):set_string("infotext", "Bouncy Level: "..id)
end end
end
local power_decrease = function(pos, node)
local id = string.sub(node.name, #node.name)
if id > "1" then
id = id - 1
minetest.add_node(pos, {name = string.sub(node.name, 1, #node.name - 1)..id})
minetest.get_meta(pos):set_string("infotext", "Bouncy Level: "..id)
end
end
for i = 1, 6 do for i = 1, 6 do
minetest.register_node("jumping:trampoline"..i, { minetest.register_node("jumping:trampoline"..i, {
@ -36,6 +46,7 @@ for i = 1, 6 do
minetest.get_meta(pos):set_string("infotext", "Bouncy Level: "..i) minetest.get_meta(pos):set_string("infotext", "Bouncy Level: "..i)
end, end,
on_punch = trampoline_punch, on_punch = trampoline_punch,
on_rightclick = power_decrease,
tiles = { tiles = {
"jumping_trampoline_top.png", "jumping_trampoline_top.png",
"jumping_trampoline_bottom.png", "jumping_trampoline_bottom.png",