mirror of
https://github.com/minetest-mods/jumping.git
synced 2024-11-26 00:53:49 +01:00
Use on_punch instead of register_on_punchnode
This commit is contained in:
parent
ec5e0d1b8a
commit
002f408185
118
jumping/init.lua
118
jumping/init.lua
@ -17,103 +17,29 @@ local cushionbox = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
minetest.register_node("jumping:trampoline1", {
|
local trampoline_punch = function(pos, node)
|
||||||
description = "Trampoline",
|
local id = string.sub(node.name, #node.name)
|
||||||
drawtype = "nodebox",
|
id = id + 1
|
||||||
node_box = trampolinebox,
|
if id == 7 then id = 1 end
|
||||||
selection_box = trampolinebox,
|
minetest.env:add_node(pos, {name = string.sub(node.name, 1, #node.name - 1)..id})
|
||||||
paramtype = "light",
|
end
|
||||||
tiles = {
|
|
||||||
"jumping_trampoline_top.png",
|
|
||||||
"jumping_trampoline_bottom.png",
|
|
||||||
"jumping_trampoline_sides.png^jumping_trampoline_sides_overlay1.png"
|
|
||||||
},
|
|
||||||
groups = {dig_immediate=2, bouncy=30, fall_damage_add_percent=-70},
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("jumping:trampoline2", {
|
for i = 1, 6 do
|
||||||
description = "Trampoline",
|
minetest.register_node("jumping:trampoline"..i, {
|
||||||
drawtype = "nodebox",
|
description = "Trampoline",
|
||||||
node_box = trampolinebox,
|
drawtype = "nodebox",
|
||||||
selection_box = trampolinebox,
|
node_box = trampolinebox,
|
||||||
paramtype = "light",
|
selection_box = trampolinebox,
|
||||||
tiles = {
|
paramtype = "light",
|
||||||
"jumping_trampoline_top.png",
|
on_punch = trampoline_punch,
|
||||||
"jumping_trampoline_bottom.png",
|
tiles = {
|
||||||
"jumping_trampoline_sides.png^jumping_trampoline_sides_overlay2.png"
|
"jumping_trampoline_top.png",
|
||||||
},
|
"jumping_trampoline_bottom.png",
|
||||||
drop = "jumping:trampoline1",
|
"jumping_trampoline_sides.png^jumping_trampoline_sides_overlay"..i..".png"
|
||||||
groups = {not_in_creative_inventory = 1, dig_immediate=2, bouncy=50, fall_damage_add_percent=-70},
|
},
|
||||||
})
|
groups = {dig_immediate=2, bouncy=20+i*20, fall_damage_add_percent=-70},
|
||||||
|
})
|
||||||
minetest.register_node("jumping:trampoline3", {
|
end
|
||||||
description = "Trampoline",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
node_box = trampolinebox,
|
|
||||||
selection_box = trampolinebox,
|
|
||||||
paramtype = "light",
|
|
||||||
tiles = {
|
|
||||||
"jumping_trampoline_top.png",
|
|
||||||
"jumping_trampoline_bottom.png",
|
|
||||||
"jumping_trampoline_sides.png^jumping_trampoline_sides_overlay3.png"
|
|
||||||
},
|
|
||||||
drop = "jumping:trampoline1",
|
|
||||||
groups = {not_in_creative_inventory = 1, dig_immediate=2, bouncy=70, fall_damage_add_percent=-70},
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("jumping:trampoline4", {
|
|
||||||
description = "Trampoline",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
node_box = trampolinebox,
|
|
||||||
selection_box = trampolinebox,
|
|
||||||
paramtype = "light",
|
|
||||||
tiles = {
|
|
||||||
"jumping_trampoline_top.png",
|
|
||||||
"jumping_trampoline_bottom.png",
|
|
||||||
"jumping_trampoline_sides.png^jumping_trampoline_sides_overlay4.png"
|
|
||||||
},
|
|
||||||
drop = "jumping:trampoline1",
|
|
||||||
groups = {not_in_creative_inventory = 1, dig_immediate=2, bouncy=90, fall_damage_add_percent=-70},
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("jumping:trampoline5", {
|
|
||||||
description = "Trampoline",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
node_box = trampolinebox,
|
|
||||||
selection_box = trampolinebox,
|
|
||||||
paramtype = "light",
|
|
||||||
tiles = {
|
|
||||||
"jumping_trampoline_top.png",
|
|
||||||
"jumping_trampoline_bottom.png",
|
|
||||||
"jumping_trampoline_sides.png^jumping_trampoline_sides_overlay5.png"
|
|
||||||
},
|
|
||||||
drop = "jumping:trampoline1",
|
|
||||||
groups = {not_in_creative_inventory = 1, dig_immediate=2, bouncy=100, fall_damage_add_percent=-70},
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("jumping:trampoline6", {
|
|
||||||
description = "Trampoline",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
node_box = trampolinebox,
|
|
||||||
selection_box = trampolinebox,
|
|
||||||
paramtype = "light",
|
|
||||||
tiles = {
|
|
||||||
"jumping_trampoline_top.png",
|
|
||||||
"jumping_trampoline_bottom.png",
|
|
||||||
"jumping_trampoline_sides.png^jumping_trampoline_sides_overlay6.png"
|
|
||||||
},
|
|
||||||
drop = "jumping:trampoline1",
|
|
||||||
groups = {not_in_creative_inventory = 1, dig_immediate=2, bouncy=110, fall_damage_add_percent=-70},
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_on_punchnode(function (pos, node)
|
|
||||||
if string.find(node.name, "jumping:trampoline") then
|
|
||||||
local id = string.sub(node.name, #node.name) --get number
|
|
||||||
id = id + 1
|
|
||||||
if id == 7 then id = 1 end
|
|
||||||
minetest.env:add_node(pos, {name = string.sub(node.name, 1, #node.name - 1)..id})
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
minetest.register_node("jumping:cushion", {
|
minetest.register_node("jumping:cushion", {
|
||||||
description = "Cushion",
|
description = "Cushion",
|
||||||
|
Loading…
Reference in New Issue
Block a user