Compare commits

...

10 Commits

Author SHA1 Message Date
ThorfinnS
4b88f2a08d
Fix incorrect sRGB profile 2020-10-22 00:49:10 +01:00
ezhh
c9ef9a88a7 Add silver and desert sandstone handholds 2018-06-20 23:16:11 +01:00
ezhh
c71cfd6570 Allow remove_handholds function to correctly handle nodes from other mods 2018-06-19 00:20:53 +01:00
ezhh
235684e89b Add API 2018-06-18 23:54:59 +01:00
ezhh
0421f06035 Fix typo that causes crash on tool use 2018-05-29 19:10:54 +01:00
Austin (SonosFuer)
e86d3b1652 Replace deprecated code with new code 2018-03-15 20:15:37 +00:00
ezhh
ec840f07f7 Update readme 2017-06-11 17:01:48 +01:00
ezhh
c1e8abcf6a Prevent problems with screwdrivers 2017-06-11 16:47:59 +01:00
ezhh
67325ac612 Fix falling nodes problem 2017-06-09 02:13:00 +01:00
ezhh
8dc78e1bda Fix descriptions 2017-05-01 18:01:16 +01:00
4 changed files with 156 additions and 85 deletions

View File

@ -3,7 +3,11 @@ handholds
Mountain climbing mod for Minetest by Shara RedCat which adds a climbing pick tool. Use the tool to add handholds to stone, desert stone, sandstone and ice which can then be climbed.
Thanks to paramat, Zeno, Billre and NathanS21 for testing and suggestions.
The tool can be crafted using diamonds and sticks.
Nodes cannot be placed directly in front of handholds, and falling nodes landing in front of handholds will remove the handholds and restore the original node.
Thanks to paramat, Zeno, LazyJ, Billre and NathanS21 for testing and suggestions.
Licenses and Attribution

235
init.lua
View File

@ -1,3 +1,6 @@
handholds = {}
handholds.nodes = {}
-- function to safely remove climbable air
local function remove_air(pos, oldnode)
@ -24,6 +27,123 @@ local function remove_air(pos, oldnode)
end
end
-- remove handholds from nodes buried under falling nodes
local function remove_handholds(pos)
local north_pos = {x = pos.x, y = pos.y, z = pos.z+1}
local south_pos = {x = pos.x, y = pos.y, z = pos.z-1}
local east_pos = {x = pos.x+1, y = pos.y, z = pos.z}
local west_pos = {x = pos.x-1, y = pos.y, z = pos.z}
local north_node = minetest.get_node(north_pos)
local south_node = minetest.get_node(south_pos)
local east_node = minetest.get_node(east_pos)
local west_node = minetest.get_node(west_pos)
local node_pos
if minetest.get_item_group(north_node.name, "handholds") == 1 and
north_node.param2 == 0 then
node_pos = north_pos
elseif minetest.get_item_group(south_node.name, "handholds") == 1 and
south_node.param2 == 2 then
node_pos = south_pos
elseif minetest.get_item_group(east_node.name, "handholds") == 1 and
east_node.param2 == 1 then
node_pos = east_pos
elseif minetest.get_item_group(west_node.name, "handholds") == 1 and
west_node.param2 == 3 then
node_pos = west_pos
end
if node_pos then
local handholds_node = string.split(minetest.get_node(node_pos).name, ":")
if handholds_node[1] == "handholds" then
minetest.set_node(node_pos, {name = "default:"..handholds_node[2]})
else
handholds_node = string.split(minetest.get_node(node_pos).name, "_")
minetest.set_node(node_pos, {name = handholds_node[1]})
end
end
end
-- handholds registration function
function handholds.register_handholds(name, def)
def.original_mod = def.original_mod or minetest.get_current_modname()
def.original_name = name
def.mod = minetest.get_current_modname()
if def.mod ~= "handholds" then
name = name .. "_handholds"
end
handholds.nodes[def.original_mod .. ":" .. def.original_name] = true
def.tiles = def.tiles or def.mod .. "_" .. def.original_name .. ".png"
minetest.register_node(":".. def.mod .. ":" .. name, {
description = def.description or "Handholds",
tiles = {
def.tiles, def.tiles, def.tiles, def.tiles, def.tiles,
def.tiles .. "^handholds_holds.png"
},
paramtype2 = "facedir",
on_rotate = function()
return false
end,
groups = def.groups or
{cracky = 3, stone = 1, not_in_creative_inventory = 1, handholds = 1},
drop = def.drop or def.mod .. ":" .. def.original_name,
sounds = def.sounds or default.node_sound_stone_defaults(),
after_destruct = function(pos, oldnode)
remove_air(pos, oldnode)
end,
})
end
-- basic handholds nodes
handholds.register_handholds("stone", {
original_mod = "default",
description = "Stone Handholds",
tiles = "default_stone.png",
drop = 'default:cobble',
})
handholds.register_handholds("desert_stone", {
original_mod = "default",
description = "Desert Stone Handholds",
tiles = "default_desert_stone.png",
drop = 'default:desert_cobble',
})
handholds.register_handholds("sandstone", {
original_mod = "default",
description = "Sandstone Handholds",
tiles = "default_sandstone.png",
drop = 'default:sandstone',
})
handholds.register_handholds("silver_sandstone", {
original_mod = "default",
description = "Silver Sandstone Handholds",
tiles = "default_silver_sandstone.png",
drop = 'default:silver_sandstone',
})
handholds.register_handholds("desert_sandstone", {
original_mod = "default",
description = "Desert Sandstone Handholds",
tiles = "default_desert_sandstone.png",
drop = 'default:desert_sandstone',
})
handholds.register_handholds("ice", {
original_mod = "default",
description = "Ice Handholds",
tiles = "default_ice.png",
drop = 'default:ice',
sounds = default.node_sound_glass_defaults(),
})
-- climbable air!
minetest.register_node("handholds:climbable_air", {
@ -36,75 +156,9 @@ minetest.register_node("handholds:climbable_air", {
diggable = false,
climbable = true,
drop = "",
groups = {not_in_creative_inventory = 1}
})
-- handholds nodes
minetest.register_node("handholds:stone", {
description = "Stone",
tiles = {
"default_stone.png", "default_stone.png",
"default_stone.png", "default_stone.png",
"default_stone.png", "default_stone.png^handholds_holds.png"
},
paramtype2 = "facedir",
groups = {cracky = 3, stone = 1, not_in_creative_inventory = 1, handholds = 1},
drop = 'default:cobble',
sounds = default.node_sound_stone_defaults(),
after_destruct = function(pos, oldnode)
remove_air(pos, oldnode)
end,
})
minetest.register_node("handholds:desert_stone", {
description = "Stone",
tiles = {
"default_desert_stone.png", "default_desert_stone.png",
"default_desert_stone.png", "default_desert_stone.png",
"default_desert_stone.png", "default_desert_stone.png^handholds_holds.png"
},
paramtype2 = "facedir",
groups = {cracky = 3, stone = 1, not_in_creative_inventory = 1, handholds = 1},
drop = 'default:desert_cobble',
sounds = default.node_sound_stone_defaults(),
after_destruct = function(pos, oldnode)
remove_air(pos, oldnode)
end,
})
minetest.register_node("handholds:sandstone", {
description = "Stone",
tiles = {
"default_sandstone.png", "default_sandstone.png",
"default_sandstone.png", "default_sandstone.png",
"default_sandstone.png", "default_sandstone.png^handholds_holds.png"
},
paramtype2 = "facedir",
groups = {cracky = 3, stone = 1, not_in_creative_inventory = 1, handholds = 1},
drop = 'default:sandstone',
sounds = default.node_sound_stone_defaults(),
after_destruct = function(pos, oldnode)
remove_air(pos, oldnode)
end,
})
minetest.register_node("handholds:ice", {
description = "Stone",
tiles = {
"default_ice.png", "default_ice.png",
"default_ice.png", "default_ice.png",
"default_ice.png", "default_ice.png^handholds_holds.png"
},
paramtype2 = "facedir",
groups = {
cracky = 3, puts_out_fire = 1, cools_lava = 1,
not_in_creative_inventory = 1, handholds = 1
},
drop = 'default:ice',
sounds = default.node_sound_glass_defaults(),
after_destruct = function(pos, oldnode)
remove_air(pos, oldnode)
groups = {not_in_creative_inventory = 1},
on_destruct = function(pos)
remove_handholds(pos)
end,
})
@ -131,21 +185,34 @@ minetest.register_tool("handholds:climbing_pick", {
end
local node_name = minetest.get_node(pointed_thing.under).name
local rotation = minetest.dir_to_facedir(
vector.subtract(pointed_thing.under, pointed_thing.above))
if node_name == "default:stone" then
minetest.set_node(pointed_thing.under,
{name = "handholds:stone", param2 = rotation})
elseif node_name == "default:desert_stone" then
minetest.set_node(pointed_thing.under,
{name = "handholds:desert_stone", param2 = rotation})
elseif node_name == "default:sandstone" then
minetest.set_node(pointed_thing.under,
{name = "handholds:sandstone", param2 = rotation})
elseif node_name == "default:ice" then
minetest.set_node(pointed_thing.under,
{name = "handholds:ice", param2 = rotation})
if handholds.nodes[node_name] then
local rotation = minetest.dir_to_facedir(
vector.subtract(pointed_thing.under, pointed_thing.above))
if node_name == "default:stone" then
minetest.set_node(pointed_thing.under,
{name = "handholds:stone", param2 = rotation})
elseif node_name == "default:desert_stone" then
minetest.set_node(pointed_thing.under,
{name = "handholds:desert_stone", param2 = rotation})
elseif node_name == "default:sandstone" then
minetest.set_node(pointed_thing.under,
{name = "handholds:sandstone", param2 = rotation})
elseif node_name == "default:silver_sandstone" then
minetest.set_node(pointed_thing.under,
{name = "handholds:silver_sandstone", param2 = rotation})
elseif node_name == "default:desert_sandstone" then
minetest.set_node(pointed_thing.under,
{name = "handholds:desert_sandstone", param2 = rotation})
elseif node_name == "default:ice" then
minetest.set_node(pointed_thing.under,
{name = "handholds:ice", param2 = rotation})
else
node_name = node_name .. "_handholds"
minetest.set_node(pointed_thing.under,
{name = node_name, param2 = rotation})
end
else
return
end
@ -156,7 +223,7 @@ minetest.register_tool("handholds:climbing_pick", {
{pos = pointed_thing.above, gain = 0.5, max_hear_distance = 8}
)
if not minetest.setting_getbool("creative_mode") then
if not minetest.settings:get_bool("creative_mode") then
local wdef = itemstack:get_definition()
itemstack:add_wear(256)
if itemstack:get_count() == 0 and wdef.sound and wdef.sound.breaks then

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 467 B