2021-07-28 01:39:38 -07:00
|
|
|
|
|
|
|
--- Cleaner
|
|
|
|
--
|
|
|
|
-- @topic tools
|
2017-08-30 14:38:48 -07:00
|
|
|
|
|
|
|
|
2017-08-30 15:15:03 -07:00
|
|
|
cleaner = {}
|
2021-05-18 18:04:33 -07:00
|
|
|
cleaner.modname = core.get_current_modname()
|
2021-05-18 18:11:24 -07:00
|
|
|
cleaner.modpath = core.get_modpath(cleaner.modname)
|
2017-08-30 14:38:48 -07:00
|
|
|
|
2021-05-18 18:04:33 -07:00
|
|
|
local cleaner_debug = core.settings:get_bool("enable_debug_mods", false)
|
2017-08-30 14:38:48 -07:00
|
|
|
|
2021-05-18 18:04:33 -07:00
|
|
|
function cleaner.log(lvl, msg)
|
|
|
|
if lvl == "debug" and not cleaner_debug then return end
|
2017-08-30 14:38:48 -07:00
|
|
|
|
2021-05-18 19:57:24 -07:00
|
|
|
if lvl and not msg then
|
|
|
|
msg = lvl
|
|
|
|
lvl = nil
|
|
|
|
end
|
|
|
|
|
2021-05-18 18:04:33 -07:00
|
|
|
msg = "[" .. cleaner.modname .. "] " .. msg
|
|
|
|
if lvl == "debug" then
|
|
|
|
msg = "[DEBUG] " .. msg
|
|
|
|
lvl = nil
|
2017-08-30 14:38:48 -07:00
|
|
|
end
|
2021-05-18 18:04:33 -07:00
|
|
|
|
2021-05-18 19:57:24 -07:00
|
|
|
if not lvl then
|
|
|
|
core.log(msg)
|
|
|
|
else
|
|
|
|
core.log(lvl, msg)
|
|
|
|
end
|
2017-08-30 14:38:48 -07:00
|
|
|
end
|
|
|
|
|
2021-07-12 18:09:54 -07:00
|
|
|
local aux = dofile(cleaner.modpath .. "/misc_functions.lua")
|
|
|
|
|
|
|
|
-- initialize world file
|
|
|
|
aux.update_world_data()
|
|
|
|
|
2017-05-18 15:06:02 -07:00
|
|
|
|
2021-05-18 18:11:24 -07:00
|
|
|
local scripts = {
|
2021-07-12 15:41:53 -07:00
|
|
|
"settings",
|
2021-07-12 08:40:45 -07:00
|
|
|
"api",
|
2021-07-12 15:39:25 -07:00
|
|
|
"chat",
|
2021-05-18 18:11:24 -07:00
|
|
|
"entities",
|
|
|
|
"nodes",
|
2021-05-26 20:54:43 -07:00
|
|
|
"items",
|
2021-07-12 18:11:37 -07:00
|
|
|
"ores",
|
2021-05-18 18:11:24 -07:00
|
|
|
}
|
2017-08-30 15:26:59 -07:00
|
|
|
|
2021-05-18 18:11:24 -07:00
|
|
|
for _, script in ipairs(scripts) do
|
|
|
|
dofile(cleaner.modpath .. "/" .. script .. ".lua")
|
2017-08-30 14:39:12 -07:00
|
|
|
end
|
2021-07-28 01:39:38 -07:00
|
|
|
|
|
|
|
|
|
|
|
local S = core.get_translator(cleaner.modname)
|
|
|
|
|
|
|
|
|
|
|
|
local sound_handle
|
|
|
|
|
|
|
|
--- Master Pencil
|
|
|
|
--
|
|
|
|
-- @tool cleaner:pencil
|
|
|
|
-- @img cleaner_pencil.png
|
|
|
|
-- @privs server
|
2021-07-29 12:40:25 -07:00
|
|
|
-- @usage
|
|
|
|
-- place (right-click):
|
|
|
|
-- - when not pointing at a node, changes modes
|
|
|
|
-- - when pointing at a node, sets node to be used
|
|
|
|
--
|
|
|
|
-- use (left-click):
|
|
|
|
-- - executes action for current mode:
|
|
|
|
-- - erase: erases pointed node
|
|
|
|
-- - write: adds node
|
|
|
|
-- - swap: replaces pointed node
|
2021-07-28 01:39:38 -07:00
|
|
|
core.register_tool(cleaner.modname .. ":pencil", {
|
|
|
|
description = S("Master Pencil"),
|
|
|
|
inventory_image = "cleaner_pencil.png",
|
|
|
|
liquids_pointable = true,
|
2021-07-29 12:32:17 -07:00
|
|
|
on_use = aux.tool.on_use,
|
|
|
|
on_secondary_use = aux.tool.on_secondary_use,
|
|
|
|
on_place = aux.tool.on_place,
|
|
|
|
})
|
|
|
|
|
|
|
|
core.register_tool(cleaner.modname .. ":pencil_1", {
|
|
|
|
description = S("Master Pencil"),
|
|
|
|
inventory_image = "cleaner_pencil.png^[transformFXFY",
|
|
|
|
liquids_pointable = true,
|
|
|
|
groups = {not_in_creative_inventory=1},
|
|
|
|
on_use = aux.tool.on_use,
|
|
|
|
on_secondary_use = aux.tool.on_secondary_use,
|
|
|
|
on_place = aux.tool.on_place,
|
2021-07-28 01:39:38 -07:00
|
|
|
})
|