Reformat files so they are easier to read and work with #2
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
unused_args = false
|
unused_args = false
|
||||||
allow_defined_top = true
|
allow_defined_top = true
|
||||||
exclude_files = {".luacheckrc"}
|
exclude_files = {".luacheckrc"}
|
||||||
@@ -18,6 +17,6 @@ read_globals = {
|
|||||||
-- MTG
|
-- MTG
|
||||||
"default", "sfinv", "creative",
|
"default", "sfinv", "creative",
|
||||||
|
|
||||||
--depends
|
-- Dependencies
|
||||||
"moretrees", "ethereal", "moreores"
|
"moretrees", "ethereal", "moreores"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,19 @@
|
|||||||
local max_stack = tonumber(minetest.settings:get("default_stack_max")) or 99
|
local max_stack = tonumber(minetest.settings:get("default_stack_max")) or 99
|
||||||
|
|
||||||
|
-- LuaFormatter off
|
||||||
|
local machine_formspec = "" ..
|
||||||
|
"size[8,9]" ..
|
||||||
|
"label[0,0;Chiseling Machine]" ..
|
||||||
|
"image[2,2;1,1;chisel.png]" ..
|
||||||
|
"list[current_name;src;2,1;1,1;]" ..
|
||||||
|
"list[current_name;dst;5,1;2,2;]" ..
|
||||||
|
"list[current_player;main;0,5;8,4;]" ..
|
||||||
|
"listring[current_name;dst]" ..
|
||||||
|
"listring[current_player;main]" ..
|
||||||
|
"listring[current_name;src]" ..
|
||||||
|
"listring[current_player;main]"
|
||||||
|
-- LuaFormatter on
|
||||||
|
|
||||||
minetest.register_node(
|
minetest.register_node(
|
||||||
"stripped_tree:chiseling_machine", {
|
"stripped_tree:chiseling_machine", {
|
||||||
description = "Chiseladora para troncos",
|
description = "Chiseladora para troncos",
|
||||||
@@ -15,10 +29,7 @@ minetest.register_node(
|
|||||||
|
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string(
|
meta:set_string("formspec", machine_formspec)
|
||||||
"formspec",
|
|
||||||
"size[8,9]label[0,0;Chiseling Machine]image[2,2;1,1;chisel.png]list[current_name;src;2,1;1,1;]list[current_name;dst;5,1;2,2;]list[current_player;main;0,5;8,4;]listring[current_name;dst]listring[current_player;main]listring[current_name;src]listring[current_player;main]"
|
|
||||||
)
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ minetest.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})
|
minetest.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 minetest.get_modpath("farming") then
|
||||||
|
|
||||||
minetest.register_craft(
|
minetest.register_craft(
|
||||||
{
|
{
|
||||||
output = "farming:string 4",
|
output = "farming:string 4",
|
||||||
@@ -35,7 +35,6 @@ minetest.register_craft(
|
|||||||
|
|
||||||
-- Register craft for mulch
|
-- Register craft for mulch
|
||||||
if minetest.get_modpath("bonemeal") then
|
if minetest.get_modpath("bonemeal") then
|
||||||
|
|
||||||
minetest.register_craft(
|
minetest.register_craft(
|
||||||
{
|
{
|
||||||
output = "bonemeal:mulch 4",
|
output = "bonemeal:mulch 4",
|
||||||
@@ -47,6 +46,7 @@ if minetest.get_modpath("bonemeal") then
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Register stripped trees
|
-- Register stripped trees
|
||||||
local mod_name = "default"
|
local mod_name = "default"
|
||||||
local trunk_names = {"tree", "jungletree", "aspen_tree", "acacia_tree", "pine_tree"}
|
local trunk_names = {"tree", "jungletree", "aspen_tree", "acacia_tree", "pine_tree"}
|
||||||
@@ -56,4 +56,3 @@ stripped_tree.register_trunk(mod_name, trunk_names)
|
|||||||
-- Register axes
|
-- Register axes
|
||||||
local axe_types = {"axe_wood", "axe_stone", "axe_bronze", "axe_steel", "axe_mese", "axe_diamond"}
|
local axe_types = {"axe_wood", "axe_stone", "axe_bronze", "axe_steel", "axe_mese", "axe_diamond"}
|
||||||
if not stripped_tree.ENABLE_CHISEL then stripped_tree.register_axes(mod_name, axe_types) end
|
if not stripped_tree.ENABLE_CHISEL then stripped_tree.register_axes(mod_name, axe_types) end
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
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
|
||||||
local creative_mode = minetest.settings:get_bool("creative_mode")
|
local creative_mode = minetest.settings:get_bool("creative_mode")
|
||||||
|
|
||||||
-- Function to verify that stripped tree trunk exists
|
-- Function to verify that stripped tree trunk exists
|
||||||
@@ -8,6 +11,7 @@ stripped_tree.has_stripped = function(pos)
|
|||||||
local node = minetest.get_node(pos).name or pos
|
local node = minetest.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 = minetest.registered_nodes[mod_name .. ":" .. "stripped_" .. node_name]
|
||||||
|
|
||||||
return has_stripped
|
return has_stripped
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -15,12 +19,14 @@ end
|
|||||||
stripped_tree.swap_node = function(pos, user, creative_mode)
|
stripped_tree.swap_node = function(pos, user, creative_mode)
|
||||||
local old_node = minetest.get_node(pos)
|
local old_node = minetest.get_node(pos)
|
||||||
local stripped = mod_name .. ":" .. "stripped_" .. node_name
|
local stripped = mod_name .. ":" .. "stripped_" .. node_name
|
||||||
|
|
||||||
minetest.swap_node(pos, {name = stripped, param2 = old_node.param2})
|
minetest.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 creative_mode then
|
||||||
local inv = user:get_inventory()
|
local inv = user:get_inventory()
|
||||||
-- check for room in inv, if not, drop item
|
|
||||||
|
-- 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
|
||||||
@@ -29,10 +35,9 @@ stripped_tree.swap_node = function(pos, user, creative_mode)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
|
|
||||||
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(
|
minetest.register_node(
|
||||||
@@ -69,7 +74,7 @@ function stripped_tree.register_trunk(mod_name, trunk_names)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- function to override axes
|
-- Function to override axes
|
||||||
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
|
||||||
@@ -89,7 +94,6 @@ if stripped_tree.ENABLE_CHISEL ~= true then
|
|||||||
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)
|
||||||
end
|
end
|
||||||
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
19
init.lua
19
init.lua
@@ -1,14 +1,14 @@
|
|||||||
-- get modpath
|
-- Get our own path
|
||||||
local mpath = minetest.get_modpath("stripped_tree")
|
local mpath = minetest.get_modpath("stripped_tree")
|
||||||
|
|
||||||
-- load functions
|
-- Load functions
|
||||||
dofile(mpath .. "/functions.lua")
|
dofile(mpath .. "/functions.lua")
|
||||||
|
|
||||||
-- load default
|
-- Load default (AKA the Minetest game)
|
||||||
dofile(mpath .. "/default.lua")
|
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 minetest.get_modpath("moretrees") then dofile(mpath .. "/moretrees.lua") end
|
||||||
|
|
||||||
if minetest.get_modpath("ethereal") then dofile(mpath .. "/ethereal.lua") end
|
if minetest.get_modpath("ethereal") then dofile(mpath .. "/ethereal.lua") end
|
||||||
@@ -16,7 +16,6 @@ if minetest.get_modpath("ethereal") then dofile(mpath .. "/ethereal.lua") end
|
|||||||
if minetest.get_modpath("moreores") then dofile(mpath .. "/moreores.lua") end
|
if minetest.get_modpath("moreores") then dofile(mpath .. "/moreores.lua") end
|
||||||
|
|
||||||
if stripped_tree.ENABLE_CHISEL then
|
if stripped_tree.ENABLE_CHISEL then
|
||||||
|
|
||||||
minetest.register_tool(
|
minetest.register_tool(
|
||||||
"stripped_tree:chisel", {
|
"stripped_tree:chisel", {
|
||||||
description = "Chisel for tree trunks",
|
description = "Chisel for tree trunks",
|
||||||
@@ -25,7 +24,6 @@ if stripped_tree.ENABLE_CHISEL then
|
|||||||
sound = {breaks = "default_tool_breaks"},
|
sound = {breaks = "default_tool_breaks"},
|
||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
|
||||||
if pointed_thing.type ~= "node" then return end
|
if pointed_thing.type ~= "node" then return end
|
||||||
|
|
||||||
local pos = pointed_thing.under
|
local pos = pointed_thing.under
|
||||||
@@ -38,9 +36,11 @@ if stripped_tree.ENABLE_CHISEL then
|
|||||||
|
|
||||||
local node = minetest.get_node(pos).name
|
local node = minetest.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 = minetest.registered_nodes[mod_name .. ":" .. "stripped_" .. node_name]
|
||||||
|
|
||||||
if has_stripped then
|
if has_stripped then
|
||||||
@@ -49,18 +49,19 @@ if stripped_tree.ENABLE_CHISEL then
|
|||||||
|
|
||||||
if not minetest.settings:get_bool("creative_mode") then
|
if not minetest.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")
|
minetest.add_item(pos, "default:tree_bark")
|
||||||
end
|
end
|
||||||
|
|
||||||
itemstack:add_wear(65535 / 299) -- 300 uses
|
itemstack:add_wear(65535 / 299) -- 300 uses
|
||||||
end
|
end
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -15,12 +15,11 @@ local trunk_names = {
|
|||||||
"rubber_tree_trunk",
|
"rubber_tree_trunk",
|
||||||
"fir_trunk",
|
"fir_trunk",
|
||||||
"jungletree_trunk",
|
"jungletree_trunk",
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stripped_tree.register_trunk(mod_name, trunk_names)
|
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(
|
minetest.register_node(
|
||||||
":" .. mod_name .. ":stripped_date_palm_mfruit_trunk", {
|
":" .. mod_name .. ":stripped_date_palm_mfruit_trunk", {
|
||||||
|
|||||||
Reference in New Issue
Block a user