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.
This commit is contained in:
26
init.lua
26
init.lua
@@ -1,5 +1,5 @@
|
||||
-- Get our own path
|
||||
local mpath = minetest.get_modpath("stripped_tree")
|
||||
local mpath = core.get_modpath("stripped_tree")
|
||||
|
||||
-- Load functions
|
||||
dofile(mpath .. "/functions.lua")
|
||||
@@ -9,14 +9,14 @@ dofile(mpath .. "/default.lua")
|
||||
dofile(mpath .. "/chiseling_machine.lua")
|
||||
|
||||
-- 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
|
||||
minetest.register_tool(
|
||||
core.register_tool(
|
||||
"stripped_tree:chisel", {
|
||||
description = "Chisel for tree trunks",
|
||||
inventory_image = "chisel.png",
|
||||
@@ -29,32 +29,32 @@ if stripped_tree.ENABLE_CHISEL then
|
||||
local pos = pointed_thing.under
|
||||
local pname = user:get_player_name()
|
||||
|
||||
if minetest.is_protected(pos, pname) then
|
||||
minetest.record_protection_violation(pos, pname)
|
||||
if core.is_protected(pos, pname) then
|
||||
core.record_protection_violation(pos, pname)
|
||||
return
|
||||
end
|
||||
|
||||
local node = minetest.get_node(pos).name
|
||||
local node = core.get_node(pos).name
|
||||
local mod_name, node_name = unpack(node:split(":"))
|
||||
|
||||
-- Before concatenating check for nil
|
||||
if not mod_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
|
||||
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()
|
||||
|
||||
-- Check for room in inv, if not, drop item
|
||||
if inv:room_for_item("main", "default:tree_bark") then
|
||||
inv:add_item("main", {name = "default:tree_bark"})
|
||||
else
|
||||
minetest.add_item(pos, "default:tree_bark")
|
||||
core.add_item(pos, "default:tree_bark")
|
||||
end
|
||||
|
||||
itemstack:add_wear(65535 / 299) -- 300 uses
|
||||
@@ -66,7 +66,7 @@ if stripped_tree.ENABLE_CHISEL then
|
||||
}
|
||||
)
|
||||
|
||||
minetest.register_craft(
|
||||
core.register_craft(
|
||||
{
|
||||
output = "stripped_tree:chisel",
|
||||
recipe = {{"", "default:steel_ingot", ""}, {"", "screwdriver:screwdriver", ""}, {"", "", ""}},
|
||||
|
||||
Reference in New Issue
Block a user