mirror of
https://github.com/minetest-mods/jumping.git
synced 2025-01-10 07:40:18 +01:00
numerous changes
Power level displayed via infotext. Right click decreases power. Power levels do not cycle (e.g. 6 - 1) Only Power Level 1 Trampoline is shown in creative Trampolines have a name according to their power level
This commit is contained in:
parent
6f64406102
commit
9870eaa3f7
44
init.lua
44
init.lua
@ -19,12 +19,15 @@ 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)
|
||||||
id = id + 1
|
local meta = minetest.get_meta(pos)
|
||||||
if id == 7 then id = 1 end
|
if id < "6" then
|
||||||
minetest.add_node(pos, {name = string.sub(node.name, 1, #node.name - 1)..id})
|
id = id + 1
|
||||||
|
minetest.add_node(pos, {name = string.sub(node.name, 1, #node.name - 1)..id})
|
||||||
|
meta:set_string("infotext", "Power Level: "..id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, 6 do
|
for i = 2, 6 do
|
||||||
minetest.register_node("jumping:trampoline"..i, {
|
minetest.register_node("jumping:trampoline"..i, {
|
||||||
description = "Trampoline",
|
description = "Trampoline",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
@ -32,15 +35,42 @@ for i = 1, 6 do
|
|||||||
selection_box = trampolinebox,
|
selection_box = trampolinebox,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
on_punch = trampoline_punch,
|
on_punch = trampoline_punch,
|
||||||
|
on_rightclick = function(pos, node)
|
||||||
|
local id = string.sub(node.name, #node.name)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
id = id - 1
|
||||||
|
minetest.add_node(pos, {name = string.sub(node.name, 1, #node.name - 1)..id})
|
||||||
|
meta:set_string("infotext", "Power Level: "..id)
|
||||||
|
end,
|
||||||
|
drop = "jumping:trampoline1",
|
||||||
tiles = {
|
tiles = {
|
||||||
"jumping_trampoline_top.png",
|
"jumping_trampoline_top.png",
|
||||||
"jumping_trampoline_bottom.png",
|
"jumping_trampoline_bottom.png",
|
||||||
"jumping_trampoline_sides.png^jumping_trampoline_sides_overlay"..i..".png"
|
"jumping_trampoline_sides.png^jumping_trampoline_sides_overlay"..i..".png"
|
||||||
},
|
},
|
||||||
groups = {dig_immediate=2, bouncy=20+i*20, fall_damage_add_percent=-70},
|
groups = {dig_immediate=2, bouncy=20+i*20, fall_damage_add_percent=-70, not_in_creative_inventory=1},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_node("jumping:trampoline1", {
|
||||||
|
description = "Trampoline",
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = trampolinebox,
|
||||||
|
selection_box = trampolinebox,
|
||||||
|
paramtype = "light",
|
||||||
|
on_punch = trampoline_punch,
|
||||||
|
on_construct = function(pos)
|
||||||
|
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},
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_node("jumping:cushion", {
|
minetest.register_node("jumping:cushion", {
|
||||||
description = "Cushion",
|
description = "Cushion",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
@ -58,8 +88,8 @@ minetest.register_node("jumping:cushion", {
|
|||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "jumping:trampoline1",
|
output = "jumping:trampoline1",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"default:wood", "default:wood", "default:wood"},
|
{"group:wood", "group:wood", "group:wood"},
|
||||||
{"default:leaves", "default:leaves", "default:leaves"},
|
{"group:leaves", "group:leaves", "group:leaves"},
|
||||||
{"default:stick", "default:stick", "default:stick"}
|
{"default:stick", "default:stick", "default:stick"}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user