mirror of
https://github.com/minetest-mods/jumping.git
synced 2024-11-16 06:50:17 +01:00
Power Level --> Bouncy Level
This commit is contained in:
parent
6422d44ccb
commit
00354bb3d9
16
init.lua
16
init.lua
|
@ -19,27 +19,27 @@ local cushionbox = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-- left click: update trampoline to increase power level
|
-- left click: update trampoline to increase bouncy level
|
||||||
local trampoline_punch = function(pos, node)
|
local trampoline_punch = function(pos, node)
|
||||||
local id = string.sub(node.name, #node.name) -- get node "id"
|
local id = string.sub(node.name, #node.name) -- get node "id"
|
||||||
local meta = minetest.get_meta(pos) -- get meta access
|
local meta = minetest.get_meta(pos) -- get meta access
|
||||||
if id < "6" then
|
if id < "6" then
|
||||||
id = id + 1 -- set id one value higher
|
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
|
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
|
meta:set_string("infotext", "Bouncy Level: "..id) -- set infotext
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- right click: update trampoline to decrease power level
|
-- right click: update trampoline to decrease bouncy level
|
||||||
local power_decrease = function(pos, node)
|
local power_decrease = function(pos, node)
|
||||||
local id = string.sub(node.name, #node.name) -- get node "id"
|
local id = string.sub(node.name, #node.name) -- get node "id"
|
||||||
local meta = minetest.get_meta(pos) -- get meta access
|
local meta = minetest.get_meta(pos) -- get meta access
|
||||||
id = id - 1 -- set id one value lower
|
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
|
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
|
meta:set_string("infotext", "Bouncy Level: "..id) -- set infotext
|
||||||
end
|
end
|
||||||
|
|
||||||
-- register trampolines of power level 2-6
|
-- register trampolines of bouncy level 2-6
|
||||||
for i = 2, 6 do
|
for i = 2, 6 do
|
||||||
minetest.register_node("jumping:trampoline"..i, {
|
minetest.register_node("jumping:trampoline"..i, {
|
||||||
description = "Trampoline",
|
description = "Trampoline",
|
||||||
|
@ -51,7 +51,7 @@ for i = 2, 6 do
|
||||||
on_rightclick = power_decrease,
|
on_rightclick = power_decrease,
|
||||||
on_construct = function(pos) -- set meta data on place
|
on_construct = function(pos) -- set meta data on place
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("infotext", "Power Level: "..i)
|
meta:set_string("infotext", "Bouncy Level: "..i)
|
||||||
end,
|
end,
|
||||||
drop = "jumping:trampoline1",
|
drop = "jumping:trampoline1",
|
||||||
tiles = {
|
tiles = {
|
||||||
|
@ -63,7 +63,7 @@ for i = 2, 6 do
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- register trampoline power level 1
|
-- register trampoline bouncy level 1
|
||||||
minetest.register_node("jumping:trampoline1", {
|
minetest.register_node("jumping:trampoline1", {
|
||||||
description = "Trampoline",
|
description = "Trampoline",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
|
@ -73,7 +73,7 @@ minetest.register_node("jumping:trampoline1", {
|
||||||
on_punch = trampoline_punch,
|
on_punch = trampoline_punch,
|
||||||
on_construct = function(pos) -- set meta data on place
|
on_construct = function(pos) -- set meta data on place
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("infotext", "Power Level: 1")
|
meta:set_string("infotext", "Bouncy Level: 1")
|
||||||
end,
|
end,
|
||||||
tiles = {
|
tiles = {
|
||||||
"jumping_trampoline_top.png",
|
"jumping_trampoline_top.png",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user