mirror of
https://github.com/mt-mods/pipeworks.git
synced 2025-06-29 23:00:49 +02:00
Replace minetest
namespace with core
(#158)
Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com>
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
local S = core.get_translator("pipeworks")
|
||||
|
||||
local has_vislib = minetest.get_modpath("vizlib")
|
||||
local has_vislib = core.get_modpath("vizlib")
|
||||
|
||||
local enable_max = minetest.settings:get_bool("pipeworks_enable_items_per_tube_limit", true)
|
||||
local max_items = tonumber(minetest.settings:get("pipeworks_max_items_per_tube")) or 30
|
||||
local enable_max = core.settings:get_bool("pipeworks_enable_items_per_tube_limit", true)
|
||||
local max_items = tonumber(core.settings:get("pipeworks_max_items_per_tube")) or 30
|
||||
max_items = math.ceil(max_items / 2) -- Limit vacuuming to half the max limit
|
||||
|
||||
local function vacuum(pos, radius)
|
||||
@ -12,7 +12,7 @@ local function vacuum(pos, radius)
|
||||
local min_pos = vector.subtract(pos, radius)
|
||||
local max_pos = vector.add(pos, radius)
|
||||
local count = 0
|
||||
for _, obj in pairs(minetest.get_objects_in_area(min_pos, max_pos)) do
|
||||
for _, obj in pairs(core.get_objects_in_area(min_pos, max_pos)) do
|
||||
local entity = obj:get_luaentity()
|
||||
if entity and entity.name == "__builtin:item" then
|
||||
if entity.itemstring ~= "" then
|
||||
@ -29,13 +29,13 @@ local function vacuum(pos, radius)
|
||||
end
|
||||
|
||||
local function set_timer(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
local timer = core.get_node_timer(pos)
|
||||
-- Randomize timer so not all tubes vacuum at the same time
|
||||
timer:start(math.random(10, 20) * 0.1)
|
||||
end
|
||||
|
||||
local function repair_tube(pos, was_node)
|
||||
minetest.swap_node(pos, {name = was_node.name, param2 = was_node.param2})
|
||||
core.swap_node(pos, {name = was_node.name, param2 = was_node.param2})
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
set_timer(pos)
|
||||
end
|
||||
@ -45,7 +45,7 @@ local function show_area(pos, node, player)
|
||||
-- Only show area when using an empty hand
|
||||
return
|
||||
end
|
||||
local radius = tonumber(minetest.get_meta(pos):get("dist")) or 2
|
||||
local radius = tonumber(core.get_meta(pos):get("dist")) or 2
|
||||
vizlib.draw_cube(pos, radius + 0.5, {player = player})
|
||||
end
|
||||
|
||||
@ -93,14 +93,14 @@ if pipeworks.enable_mese_sand_tube then
|
||||
on_repair = repair_tube,
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
meta:set_int("dist", 2)
|
||||
meta:set_string("formspec", formspec)
|
||||
meta:set_string("infotext", S("Adjustable Vacuuming Tube (@1m)", 2))
|
||||
set_timer(pos)
|
||||
end,
|
||||
on_timer = function(pos, elapsed)
|
||||
local radius = minetest.get_meta(pos):get_int("dist")
|
||||
local radius = core.get_meta(pos):get_int("dist")
|
||||
vacuum(pos, radius)
|
||||
set_timer(pos)
|
||||
end,
|
||||
@ -108,7 +108,7 @@ if pipeworks.enable_mese_sand_tube then
|
||||
if not fields.dist or not pipeworks.may_configure(pos, sender) then
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local dist = math.min(math.max(tonumber(fields.dist) or 0, 0), 8)
|
||||
meta:set_int("dist", dist)
|
||||
meta:set_string("infotext", S("Adjustable Vacuuming Tube (@1m)", dist))
|
||||
@ -118,7 +118,7 @@ if pipeworks.enable_mese_sand_tube then
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_lbm({
|
||||
core.register_lbm({
|
||||
label = "Vacuum tube node timer starter",
|
||||
name = "pipeworks:vacuum_tube_start",
|
||||
nodenames = {"group:vacuum_tube"},
|
||||
|
Reference in New Issue
Block a user