From c7223539f6dc0149c4492dc86afbaa1f00d3eca6 Mon Sep 17 00:00:00 2001 From: Alexander Weber Date: Mon, 23 Apr 2018 20:10:19 +0200 Subject: [PATCH] increade by punch, decrease by rightclick --- init.lua | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index e1e40af..28c78ae 100644 --- a/init.lua +++ b/init.lua @@ -19,10 +19,20 @@ local cushionbox = { local trampoline_punch = function(pos, node) local id = string.sub(node.name, #node.name) - 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.get_meta(pos):set_string("infotext", "Bouncy Level: "..id) + if id < "6" 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 + +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 @@ -36,6 +46,7 @@ for i = 1, 6 do minetest.get_meta(pos):set_string("infotext", "Bouncy Level: "..i) end, on_punch = trampoline_punch, + on_rightclick = power_decrease, tiles = { "jumping_trampoline_top.png", "jumping_trampoline_bottom.png",