Compare commits

5 Commits

Author SHA1 Message Date
1e1c9a0fb4 Make strings translatable
Some checks are pending
build / build (push) Waiting to run
build / build (pull_request) Waiting to run
Also add Hungarian and Spanish translations
2025-12-17 12:50:26 +01:00
97682b7df6 Add title and description to mod.conf 2025-12-17 09:49:58 +01:00
6f1d331771 Pass the current tool to the stripped_tree.swap_node function
Some checks failed
build / build (pull_request) Waiting to run
build / build (push) Has been cancelled
2025-12-16 19:54:11 +01:00
880a60b7e0 Fix a bug that prevents log stripping with an axe 2025-12-16 19:54:11 +01:00
52c4bc4391 Use core instead of minetest
`core` is the preferred object to use, existing since Minetest 0.4 or something; `minetest` is just a backwards
compatibility alias for it.
2025-12-16 19:54:10 +01:00
10 changed files with 81 additions and 57 deletions

View File

@@ -12,7 +12,7 @@ read_globals = {
table = {fields = {"copy", "getn"}}, table = {fields = {"copy", "getn"}},
-- Builtin -- Builtin
"minetest", "core", "vector", "ItemStack", "core", "vector", "ItemStack",
"dump", "DIR_DELIM", "VoxelArea", "Settings", "dump", "DIR_DELIM", "VoxelArea", "Settings",
-- MTG -- MTG

View File

@@ -1,9 +1,11 @@
local max_stack = tonumber(minetest.settings:get("default_stack_max")) or 99 local S = core.get_translator(core.get_current_modname())
local max_stack = tonumber(core.settings:get("default_stack_max")) or 99
-- LuaFormatter off -- LuaFormatter off
local machine_formspec = "" .. local machine_formspec = "" ..
"size[8,9]" .. "size[8,9]" ..
"label[0,0;Chiseling Machine]" .. "label[0,0;" .. core.formspec_escape(S("Chiseling Machine")) .. "]" ..
"image[2,2;1,1;chisel.png]" .. "image[2,2;1,1;chisel.png]" ..
"list[current_name;src;2,1;1,1;]" .. "list[current_name;src;2,1;1,1;]" ..
"list[current_name;dst;5,1;2,2;]" .. "list[current_name;dst;5,1;2,2;]" ..
@@ -14,9 +16,9 @@ local machine_formspec = "" ..
"listring[current_player;main]" "listring[current_player;main]"
-- LuaFormatter on -- LuaFormatter on
minetest.register_node( core.register_node(
"stripped_tree:chiseling_machine", { "stripped_tree:chiseling_machine", {
description = "Chiseladora para troncos", description = S("Chiseling Machine"),
tiles = { tiles = {
"chiseling_machine.png", "chiseling_machine.png",
"chiseling_machine.png", "chiseling_machine.png",
@@ -28,19 +30,19 @@ minetest.register_node(
groups = {cracky = 1}, groups = {cracky = 1},
after_place_node = function(pos, placer) after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos) local meta = core.get_meta(pos)
meta:set_string("formspec", machine_formspec) meta:set_string("formspec", machine_formspec)
end, end,
on_construct = function(pos) on_construct = function(pos)
local inv = minetest.get_meta(pos):get_inventory() local inv = core.get_meta(pos):get_inventory()
inv:set_size("src", 1) inv:set_size("src", 1)
inv:set_size("dst", 2) inv:set_size("dst", 2)
minetest.get_node_timer(pos):start(1.0) core.get_node_timer(pos):start(1.0)
end, end,
on_metadata_inventory_put = function(pos, listname, index, stack, player) on_metadata_inventory_put = function(pos, listname, index, stack, player)
local inv = minetest.get_meta(pos):get_inventory() local inv = core.get_meta(pos):get_inventory()
local src_stack = inv:get_stack("src", 1) local src_stack = inv:get_stack("src", 1)
local dst_stack = inv:get_stack("dst", 1) local dst_stack = inv:get_stack("dst", 1)
if listname == "src" and not src_stack:is_empty() then if listname == "src" and not src_stack:is_empty() then
@@ -48,7 +50,7 @@ minetest.register_node(
local src_count = src_stack:get_count() local src_count = src_stack:get_count()
local mod_name, node_name = unpack(src_name:split(":")) local mod_name, node_name = unpack(src_name:split(":"))
local stripped_name = mod_name .. ":stripped_" .. node_name local stripped_name = mod_name .. ":stripped_" .. node_name
local has_stripped = minetest.registered_nodes[stripped_name] local has_stripped = core.registered_nodes[stripped_name]
local dst_count = dst_stack:get_count() local dst_count = dst_stack:get_count()
if has_stripped and dst_count < max_stack then if has_stripped and dst_count < max_stack then
inv:add_item("dst", stripped_name .. " " .. src_count) inv:add_item("dst", stripped_name .. " " .. src_count)
@@ -69,7 +71,7 @@ minetest.register_node(
} }
) )
minetest.register_craft( core.register_craft(
{ {
output = "stripped_tree:chiseling_machine", output = "stripped_tree:chiseling_machine",
recipe = { recipe = {

View File

@@ -1,15 +1,15 @@
-- Register tree bark -- Register tree bark
minetest.register_craftitem( core.register_craftitem(
":default:tree_bark", ":default:tree_bark",
{description = "Tree bark", inventory_image = "tree_bark.png", groups = {not_in_creative_inventory = 1}} {description = "Tree bark", inventory_image = "tree_bark.png", groups = {not_in_creative_inventory = 1}}
) )
-- Register bark as fuel -- Register bark as fuel
minetest.register_craft({type = "fuel", recipe = "default:tree_bark", burntime = 15}) core.register_craft({type = "fuel", recipe = "default:tree_bark", burntime = 15})
-- Register craft for string -- Register craft for string
if minetest.get_modpath("farming") then if core.get_modpath("farming") then
minetest.register_craft( core.register_craft(
{ {
output = "farming:string 4", output = "farming:string 4",
recipe = { recipe = {
@@ -22,7 +22,7 @@ if minetest.get_modpath("farming") then
end end
-- Register craft for paper -- Register craft for paper
minetest.register_craft( core.register_craft(
{ {
output = "default:paper 8", output = "default:paper 8",
recipe = { recipe = {
@@ -34,8 +34,8 @@ minetest.register_craft(
) )
-- Register craft for mulch -- Register craft for mulch
if minetest.get_modpath("bonemeal") then if core.get_modpath("bonemeal") then
minetest.register_craft( core.register_craft(
{ {
output = "bonemeal:mulch 4", output = "bonemeal:mulch 4",
recipe = { recipe = {

View File

@@ -1,48 +1,51 @@
local S = core.get_translator(core.get_current_modname())
stripped_tree = {} stripped_tree = {}
-- Select between chisel tool or axes. -- Select between chisel tool or axes.
stripped_tree.ENABLE_CHISEL = core.settings:get_bool("stripped_tree_enable_chisel") stripped_tree.ENABLE_CHISEL = core.settings:get_bool("stripped_tree_enable_chisel")
-- Check if we are running on a creative server -- Check if we are running on a creative server
local creative_mode = minetest.settings:get_bool("creative_mode") local creative_mode = core.settings:get_bool("creative_mode")
-- Function to verify that stripped tree trunk exists -- Function to verify that stripped tree trunk exists
stripped_tree.has_stripped = function(pos) stripped_tree.has_stripped = function(pos)
local node = minetest.get_node(pos).name or pos local node = core.get_node(pos).name or pos
local mod_name, node_name = unpack(node:split(":")) local mod_name, node_name = unpack(node:split(":"))
local has_stripped = minetest.registered_nodes[mod_name .. ":" .. "stripped_" .. node_name] local has_stripped = core.registered_nodes[mod_name .. ":" .. "stripped_" .. node_name]
return has_stripped return has_stripped
end end
-- Function to swap nodes -- Function to swap nodes
stripped_tree.swap_node = function(pos, user, creative_mode) stripped_tree.swap_node = function(pos, user, in_creative_mode, tool)
local old_node = minetest.get_node(pos) local old_node = core.get_node(pos).name
local mod_name, node_name = unpack(old_node:split(":"))
local stripped = mod_name .. ":" .. "stripped_" .. node_name local stripped = mod_name .. ":" .. "stripped_" .. node_name
minetest.swap_node(pos, {name = stripped, param2 = old_node.param2}) core.swap_node(pos, {name = stripped, param2 = old_node.param2})
-- itemstack:add_wear(65535 / 299) this is not useful at moment. -- itemstack:add_wear(65535 / 299) this is not useful at moment.
if not creative_mode then if not in_creative_mode then
local inv = user:get_inventory() local inv = user:get_inventory()
-- If the player has room in their inventory for a bark, give them one; otherwise, drop the bark to the ground. -- If the player has room in their inventory for a bark, give them one; otherwise, drop the bark to the ground.
if inv:room_for_item("main", "default:tree_bark") then if inv:room_for_item("main", "default:tree_bark") then
inv:add_item("main", {name = "default:tree_bark"}) inv:add_item("main", {name = "default:tree_bark"})
else else
minetest.add_item(pos, "default:tree_bark") core.add_item(pos, "default:tree_bark")
end end
end end
return itemstack return tool
end end
-- Function to register nodes -- Function to register nodes
function stripped_tree.register_trunk(mod_name, trunk_names) function stripped_tree.register_trunk(mod_name, trunk_names)
for _, name in ipairs(trunk_names) do for _, name in ipairs(trunk_names) do
minetest.register_node( core.register_node(
":" .. mod_name .. ":stripped_" .. name, { ":" .. mod_name .. ":stripped_" .. name, {
description = "Stripped " .. name, description = S("Stripped @1", name),
tiles = { tiles = {
"stripped_" .. mod_name .. "_" .. name .. "_top.png", "stripped_" .. mod_name .. "_" .. name .. "_top.png",
"stripped_" .. mod_name .. "_" .. name .. "_top.png", "stripped_" .. mod_name .. "_" .. name .. "_top.png",
@@ -57,11 +60,11 @@ function stripped_tree.register_trunk(mod_name, trunk_names)
}, },
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
paramtype2 = "facedir", paramtype2 = "facedir",
on_place = minetest.rotate_node, on_place = core.rotate_node,
} }
) )
minetest.register_craft( core.register_craft(
{ {
output = mod_name .. ":" .. name, output = mod_name .. ":" .. name,
recipe = { recipe = {
@@ -78,7 +81,7 @@ end
if stripped_tree.ENABLE_CHISEL ~= true then if stripped_tree.ENABLE_CHISEL ~= true then
function stripped_tree.register_axes(mod_n, axe_types) function stripped_tree.register_axes(mod_n, axe_types)
for _, axe_name in ipairs(axe_types) do for _, axe_name in ipairs(axe_types) do
minetest.override_item( core.override_item(
mod_n .. ":" .. axe_name, { mod_n .. ":" .. axe_name, {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end if pointed_thing.type ~= "node" then return end
@@ -86,13 +89,13 @@ if stripped_tree.ENABLE_CHISEL ~= true then
local pos = pointed_thing.under local pos = pointed_thing.under
local pname = user:get_player_name() local pname = user:get_player_name()
if minetest.is_protected(pos, pname) then if core.is_protected(pos, pname) then
minetest.record_protection_violation(pos, pname) core.record_protection_violation(pos, pname)
return return
end end
if stripped_tree.has_stripped(pos) then if stripped_tree.has_stripped(pos) then
stripped_tree.swap_node(pos, user, creative_mode) stripped_tree.swap_node(pos, user, creative_mode, itemstack)
end end
end, end,
} }

View File

@@ -1,5 +1,7 @@
-- Get our own path -- Get our own path
local mpath = minetest.get_modpath("stripped_tree") local mpath = core.get_modpath("stripped_tree")
local S = core.get_translator(core.get_current_modname())
-- Load functions -- Load functions
dofile(mpath .. "/functions.lua") dofile(mpath .. "/functions.lua")
@@ -9,16 +11,16 @@ dofile(mpath .. "/default.lua")
dofile(mpath .. "/chiseling_machine.lua") dofile(mpath .. "/chiseling_machine.lua")
-- Load optional dependencies -- Load optional dependencies
if minetest.get_modpath("moretrees") then dofile(mpath .. "/moretrees.lua") end if core.get_modpath("moretrees") then dofile(mpath .. "/moretrees.lua") end
if minetest.get_modpath("ethereal") then dofile(mpath .. "/ethereal.lua") end if core.get_modpath("ethereal") then dofile(mpath .. "/ethereal.lua") end
if minetest.get_modpath("moreores") then dofile(mpath .. "/moreores.lua") end if core.get_modpath("moreores") then dofile(mpath .. "/moreores.lua") end
if stripped_tree.ENABLE_CHISEL then if stripped_tree.ENABLE_CHISEL then
minetest.register_tool( core.register_tool(
"stripped_tree:chisel", { "stripped_tree:chisel", {
description = "Chisel for tree trunks", description = S("Chisel for tree trunks"),
inventory_image = "chisel.png", inventory_image = "chisel.png",
wield_image = "chisel.png", wield_image = "chisel.png",
sound = {breaks = "default_tool_breaks"}, sound = {breaks = "default_tool_breaks"},
@@ -29,32 +31,32 @@ if stripped_tree.ENABLE_CHISEL then
local pos = pointed_thing.under local pos = pointed_thing.under
local pname = user:get_player_name() local pname = user:get_player_name()
if minetest.is_protected(pos, pname) then if core.is_protected(pos, pname) then
minetest.record_protection_violation(pos, pname) core.record_protection_violation(pos, pname)
return return
end end
local node = minetest.get_node(pos).name local node = core.get_node(pos).name
local mod_name, node_name = unpack(node:split(":")) local mod_name, node_name = unpack(node:split(":"))
-- Before concatenating check for nil -- Before concatenating check for nil
if not mod_name then return end if not mod_name then return end
if not node_name then return end if not node_name then return end
local has_stripped = minetest.registered_nodes[mod_name .. ":" .. "stripped_" .. node_name] local has_stripped = core.registered_nodes[mod_name .. ":" .. "stripped_" .. node_name]
if has_stripped then if has_stripped then
local stripped = mod_name .. ":" .. "stripped_" .. node_name local stripped = mod_name .. ":" .. "stripped_" .. node_name
minetest.swap_node(pos, {name = stripped}) core.swap_node(pos, {name = stripped})
if not minetest.settings:get_bool("creative_mode") then if not core.settings:get_bool("creative_mode") then
local inv = user:get_inventory() local inv = user:get_inventory()
-- Check for room in inv, if not, drop item -- Check for room in inv, if not, drop item
if inv:room_for_item("main", "default:tree_bark") then if inv:room_for_item("main", "default:tree_bark") then
inv:add_item("main", {name = "default:tree_bark"}) inv:add_item("main", {name = "default:tree_bark"})
else else
minetest.add_item(pos, "default:tree_bark") core.add_item(pos, "default:tree_bark")
end end
itemstack:add_wear(65535 / 299) -- 300 uses itemstack:add_wear(65535 / 299) -- 300 uses
@@ -66,7 +68,7 @@ if stripped_tree.ENABLE_CHISEL then
} }
) )
minetest.register_craft( core.register_craft(
{ {
output = "stripped_tree:chisel", output = "stripped_tree:chisel",
recipe = {{"", "default:steel_ingot", ""}, {"", "screwdriver:screwdriver", ""}, {"", "", ""}}, recipe = {{"", "default:steel_ingot", ""}, {"", "screwdriver:screwdriver", ""}, {"", "", ""}},

View File

@@ -0,0 +1,5 @@
# textdomain: stripped_tree
Chiseling Machine=Cinceladora para troncos
Stripped @1=@1 cincelado
Tree bark=Corteza de árbol
Chisel for tree trunks=Cincel de tronco

View File

@@ -0,0 +1,5 @@
# textdomain: stripped_tree
Chiseling Machine=Kéregvéső Gép
Stripped @1=Kérgezett @1
Tree bark=Fakéreg
Chisel for tree trunks=Kéregvéső

5
locale/template.txt Normal file
View File

@@ -0,0 +1,5 @@
# textdomain: stripped_tree
Chiseling Machine=
Stripped @1=
Tree bark=
Chisel for tree trunks=

View File

@@ -1,4 +1,6 @@
name = stripped_tree name = stripped_tree
title = Stripped Trees
description = Adds stripped tree trunks
author = 1faco author = 1faco
depends = default depends = default
optional_depends = moretrees, ethereal, moreores optional_depends = moretrees, ethereal, moreores

View File

@@ -21,7 +21,7 @@ stripped_tree.register_trunk(mod_name, trunk_names)
-- Register tree variations using the same texture as default moretree trunks -- Register tree variations using the same texture as default moretree trunks
minetest.register_node( core.register_node(
":" .. mod_name .. ":stripped_date_palm_mfruit_trunk", { ":" .. mod_name .. ":stripped_date_palm_mfruit_trunk", {
description = "Stripped date_palm_fruit_trunk", description = "Stripped date_palm_fruit_trunk",
tiles = { tiles = {
@@ -32,11 +32,11 @@ minetest.register_node(
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1}, groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
paramtype2 = "facedir", paramtype2 = "facedir",
on_place = minetest.rotate_node, on_place = core.rotate_node,
} }
) )
minetest.register_node( core.register_node(
":" .. mod_name .. ":stripped_date_palm_ffruit_trunk", { ":" .. mod_name .. ":stripped_date_palm_ffruit_trunk", {
description = "Stripped date_palm_fruit_trunk", description = "Stripped date_palm_fruit_trunk",
tiles = { tiles = {
@@ -47,11 +47,11 @@ minetest.register_node(
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1}, groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
paramtype2 = "facedir", paramtype2 = "facedir",
on_place = minetest.rotate_node, on_place = core.rotate_node,
} }
) )
minetest.register_node( core.register_node(
":" .. mod_name .. ":stripped_date_palm_fruit_trunk", { ":" .. mod_name .. ":stripped_date_palm_fruit_trunk", {
description = "Stripped date_palm_fruit_trunk", description = "Stripped date_palm_fruit_trunk",
tiles = { tiles = {
@@ -62,11 +62,11 @@ minetest.register_node(
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1}, groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
paramtype2 = "facedir", paramtype2 = "facedir",
on_place = minetest.rotate_node, on_place = core.rotate_node,
} }
) )
minetest.register_node( core.register_node(
":" .. mod_name .. ":stripped_rubber_tree_trunk_empty", { ":" .. mod_name .. ":stripped_rubber_tree_trunk_empty", {
description = "Stripped date_palm_fruit_trunk", description = "Stripped date_palm_fruit_trunk",
tiles = { tiles = {
@@ -77,6 +77,6 @@ minetest.register_node(
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1}, groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
paramtype2 = "facedir", paramtype2 = "facedir",
on_place = minetest.rotate_node, on_place = core.rotate_node,
} }
) )