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,13 +1,13 @@
|
||||
local materials = xcompat.materials
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
local S = core.get_translator("pipeworks")
|
||||
|
||||
local straight = function(pos, node, velocity, stack) return {velocity} end
|
||||
local steel_tex = "[combine:16x16^[noalpha^[colorize:#D3D3D3"
|
||||
if minetest.get_modpath("default") then steel_tex = "default_steel_block.png" end
|
||||
if core.get_modpath("default") then steel_tex = "default_steel_block.png" end
|
||||
|
||||
-- register an embedded tube
|
||||
function pipeworks.register_embedded_tube(nodename, opts)
|
||||
minetest.register_node(nodename, {
|
||||
core.register_node(nodename, {
|
||||
description = opts.description,
|
||||
tiles = {
|
||||
opts.base_texture,
|
||||
@ -41,7 +41,7 @@ function pipeworks.register_embedded_tube(nodename, opts)
|
||||
priority = 50,
|
||||
can_go = straight,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local dir = minetest.facedir_to_dir(node.param2)
|
||||
local dir = core.facedir_to_dir(node.param2)
|
||||
return vector.equals(dir, direction) or vector.equals(vector.multiply(dir, -1), direction)
|
||||
end
|
||||
},
|
||||
@ -50,7 +50,7 @@ function pipeworks.register_embedded_tube(nodename, opts)
|
||||
on_rotate = pipeworks.on_rotate,
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
core.register_craft( {
|
||||
output = nodename .. " 1",
|
||||
recipe = {
|
||||
{ opts.base_ingredient, opts.base_ingredient, opts.base_ingredient },
|
||||
|
100
tubes/lua.lua
100
tubes/lua.lua
@ -26,10 +26,12 @@
|
||||
-- use too much memory from the sandbox.
|
||||
-- You can add more functions to the environment
|
||||
-- (see where local env is defined)
|
||||
-- Something nice to play is appending minetest.env to it.
|
||||
-- Something nice to play is appending core.env to it.
|
||||
|
||||
local BASENAME = "pipeworks:lua_tube"
|
||||
|
||||
local has_digilines = core.get_modpath("digilines")
|
||||
|
||||
local rules = {
|
||||
red = {x = -1, y = 0, z = 0, name = "red"},
|
||||
blue = {x = 1, y = 0, z = 0, name = "blue"},
|
||||
@ -63,7 +65,7 @@ local digiline_rules_luatube = {
|
||||
-- These helpers are required to set the port states of the lua_tube
|
||||
|
||||
local function update_real_port_states(pos, rule_name, new_state)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
if rule_name == nil then
|
||||
meta:set_int("real_portstates", 1)
|
||||
return
|
||||
@ -100,7 +102,7 @@ local port_names = {"red", "blue", "yellow", "green", "black", "white"}
|
||||
|
||||
local function get_real_port_states(pos)
|
||||
-- Determine if ports are powered (by itself or from outside)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local L = {}
|
||||
local n = meta:get_int("real_portstates") - 1
|
||||
for _, name in ipairs(port_names) do
|
||||
@ -153,10 +155,10 @@ end
|
||||
|
||||
|
||||
local function set_port_states(pos, ports)
|
||||
local node = minetest.get_node(pos)
|
||||
local node = core.get_node(pos)
|
||||
local name = node.name
|
||||
clean_port_states(ports)
|
||||
local vports = minetest.registered_nodes[name].virtual_portstates
|
||||
local vports = core.registered_nodes[name].virtual_portstates
|
||||
local new_name = generate_name(ports)
|
||||
|
||||
if name ~= new_name and vports then
|
||||
@ -169,17 +171,17 @@ local function set_port_states(pos, ports)
|
||||
-- its output off.
|
||||
-- Solution / Workaround:
|
||||
-- Remember which output was turned off and ignore next "off" event.
|
||||
local meta = minetest.get_meta(pos)
|
||||
local ign = minetest.deserialize(meta:get_string("ignore_offevents"), true) or {}
|
||||
local meta = core.get_meta(pos)
|
||||
local ign = core.deserialize(meta:get_string("ignore_offevents"), true) or {}
|
||||
if ports.red and not vports.red and not mesecon.is_powered(pos, rules.red) then ign.red = true end
|
||||
if ports.blue and not vports.blue and not mesecon.is_powered(pos, rules.blue) then ign.blue = true end
|
||||
if ports.yellow and not vports.yellow and not mesecon.is_powered(pos, rules.yellow) then ign.yellow = true end
|
||||
if ports.green and not vports.green and not mesecon.is_powered(pos, rules.green) then ign.green = true end
|
||||
if ports.black and not vports.black and not mesecon.is_powered(pos, rules.black) then ign.black = true end
|
||||
if ports.white and not vports.white and not mesecon.is_powered(pos, rules.white) then ign.white = true end
|
||||
meta:set_string("ignore_offevents", minetest.serialize(ign))
|
||||
meta:set_string("ignore_offevents", core.serialize(ign))
|
||||
|
||||
minetest.swap_node(pos, {name = new_name, param2 = node.param2})
|
||||
core.swap_node(pos, {name = new_name, param2 = node.param2})
|
||||
|
||||
if ports.red ~= vports.red then set_port(pos, rules.red, ports.red) end
|
||||
if ports.blue ~= vports.blue then set_port(pos, rules.blue, ports.blue) end
|
||||
@ -195,12 +197,12 @@ end
|
||||
-- Overheating --
|
||||
-----------------
|
||||
local function burn_controller(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local node = core.get_node(pos)
|
||||
node.name = BASENAME.."_burnt"
|
||||
minetest.swap_node(pos, node)
|
||||
minetest.get_meta(pos):set_string("lc_memory", "");
|
||||
core.swap_node(pos, node)
|
||||
core.get_meta(pos):set_string("lc_memory", "");
|
||||
-- Wait for pending operations
|
||||
minetest.after(0.2, mesecon.receptor_off, pos, mesecon.rules.flat)
|
||||
core.after(0.2, mesecon.receptor_off, pos, mesecon.rules.flat)
|
||||
end
|
||||
|
||||
local function overheat(pos, meta)
|
||||
@ -216,10 +218,10 @@ end
|
||||
|
||||
local function ignore_event(event, meta)
|
||||
if event.type ~= "off" then return false end
|
||||
local ignore_offevents = minetest.deserialize(meta:get_string("ignore_offevents"), true) or {}
|
||||
local ignore_offevents = core.deserialize(meta:get_string("ignore_offevents"), true) or {}
|
||||
if ignore_offevents[event.pin.name] then
|
||||
ignore_offevents[event.pin.name] = nil
|
||||
meta:set_string("ignore_offevents", minetest.serialize(ignore_offevents))
|
||||
meta:set_string("ignore_offevents", core.serialize(ignore_offevents))
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -229,11 +231,11 @@ end
|
||||
-------------------------
|
||||
|
||||
local function safe_print(param)
|
||||
if (minetest.settings:get("pipeworks_lua_tube_print_behavior") or "log") == "log" then
|
||||
if (core.settings:get("pipeworks_lua_tube_print_behavior") or "log") == "log" then
|
||||
local string_meta = getmetatable("")
|
||||
local sandbox = string_meta.__index
|
||||
string_meta.__index = string -- Leave string sandbox temporarily
|
||||
minetest.log("action", string.format("[pipeworks.tubes.lua] print(%s)", dump(param)))
|
||||
core.log("action", string.format("[pipeworks.tubes.lua] print(%s)", dump(param)))
|
||||
string_meta.__index = sandbox -- Restore string sandbox
|
||||
end
|
||||
end
|
||||
@ -307,7 +309,7 @@ if mesecon.setting("luacontroller_lightweight_interrupts", false) then
|
||||
return (function(time, iid)
|
||||
if type(time) ~= "number" then error("Delay must be a number") end
|
||||
if iid ~= nil then send_warning("Interrupt IDs are disabled on this server") end
|
||||
table.insert(itbl, function() minetest.get_node_timer(pos):start(time) end)
|
||||
table.insert(itbl, function() core.get_node_timer(pos):start(time) end)
|
||||
end)
|
||||
end
|
||||
else
|
||||
@ -321,12 +323,12 @@ else
|
||||
if type(time) ~= "number" then error("Delay must be a number") end
|
||||
table.insert(itbl, function ()
|
||||
-- Outside string metatable sandbox, can safely run this now
|
||||
local luac_id = minetest.get_meta(pos):get_int("luac_id")
|
||||
local luac_id = core.get_meta(pos):get_int("luac_id")
|
||||
-- Check if IID is dodgy, so you can't use interrupts to store an infinite amount of data.
|
||||
-- Note that this is safe from alter-after-free because this code gets run after the sandbox has ended.
|
||||
-- This runs outside of the timer and *shouldn't* harm perf. unless dodgy data is being sent in the first place
|
||||
iid = remove_functions(iid)
|
||||
local msg_ser = minetest.serialize(iid)
|
||||
local msg_ser = core.serialize(iid)
|
||||
if #msg_ser <= mesecon.setting("luacontroller_interruptid_maxlen", 256) then
|
||||
mesecon.queue:add_action(pos, "pipeworks:lc_tube_interrupt", {luac_id, iid}, time, iid, 1)
|
||||
else
|
||||
@ -430,7 +432,7 @@ end
|
||||
|
||||
-- itbl: Flat table of functions to run after sandbox cleanup, used to prevent various security hazards
|
||||
local function get_digiline_send(pos, itbl, send_warning)
|
||||
if not minetest.get_modpath("digilines") then return end
|
||||
if not has_digilines then return end
|
||||
local chan_maxlen = mesecon.setting("luacontroller_digiline_channel_maxlen", 256)
|
||||
local maxlen = mesecon.setting("luacontroller_digiline_maxlen", 50000)
|
||||
return function(channel, msg)
|
||||
@ -456,7 +458,7 @@ local function get_digiline_send(pos, itbl, send_warning)
|
||||
|
||||
table.insert(itbl, function ()
|
||||
-- Runs outside of string metatable sandbox
|
||||
local luac_id = minetest.get_meta(pos):get_int("luac_id")
|
||||
local luac_id = core.get_meta(pos):get_int("luac_id")
|
||||
mesecon.queue:add_action(pos, "pipeworks:lt_digiline_relay", {channel, luac_id, msg})
|
||||
end)
|
||||
return true
|
||||
@ -471,7 +473,7 @@ local safe_globals = {
|
||||
|
||||
local function create_environment(pos, mem, event, itbl, send_warning)
|
||||
-- Make sure the tube hasn't broken.
|
||||
local vports = minetest.registered_nodes[minetest.get_node(pos).name].virtual_portstates
|
||||
local vports = core.registered_nodes[core.get_node(pos).name].virtual_portstates
|
||||
if not vports then return {} end
|
||||
|
||||
-- Gather variables for the environment
|
||||
@ -593,19 +595,19 @@ end
|
||||
|
||||
|
||||
local function load_memory(meta)
|
||||
return minetest.deserialize(meta:get_string("lc_memory"), true) or {}
|
||||
return core.deserialize(meta:get_string("lc_memory"), true) or {}
|
||||
end
|
||||
|
||||
|
||||
local function save_memory(pos, meta, mem)
|
||||
local memstring = minetest.serialize(remove_functions(mem))
|
||||
local memstring = core.serialize(remove_functions(mem))
|
||||
local memsize_max = mesecon.setting("luacontroller_memsize", 100000)
|
||||
|
||||
if (#memstring <= memsize_max) then
|
||||
meta:set_string("lc_memory", memstring)
|
||||
meta:mark_as_private("lc_memory")
|
||||
else
|
||||
minetest.log("info", "lua_tube memory overflow. "..memsize_max.." bytes available, "
|
||||
core.log("info", "lua_tube memory overflow. "..memsize_max.." bytes available, "
|
||||
..#memstring.." required. Controller overheats.")
|
||||
burn_controller(pos)
|
||||
end
|
||||
@ -614,7 +616,7 @@ end
|
||||
-- Returns success (boolean), errmsg (string), retval(any, return value of the user supplied code)
|
||||
-- run (as opposed to run_inner) is responsible for setting up meta according to this output
|
||||
local function run_inner(pos, code, event)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
-- Note: These return success, presumably to avoid changing LC ID.
|
||||
if overheat(pos) then return true, "", nil end
|
||||
if ignore_event(event, meta) then return true, "", nil end
|
||||
@ -668,8 +670,8 @@ end
|
||||
local function reset_formspec(meta, code, errmsg)
|
||||
meta:set_string("code", code)
|
||||
meta:mark_as_private("code")
|
||||
code = minetest.formspec_escape(code or "")
|
||||
errmsg = minetest.formspec_escape(tostring(errmsg or ""))
|
||||
code = core.formspec_escape(code or "")
|
||||
errmsg = core.formspec_escape(tostring(errmsg or ""))
|
||||
meta:set_string("formspec", "size[12,10]"
|
||||
.."style_type[label,textarea;font=mono]"
|
||||
.."background[-0.2,-0.25;12.4,10.75;jeija_luac_background.png]"
|
||||
@ -681,14 +683,14 @@ local function reset_formspec(meta, code, errmsg)
|
||||
end
|
||||
|
||||
local function reset_meta(pos, code, errmsg)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
reset_formspec(meta, code, errmsg)
|
||||
meta:set_int("luac_id", math.random(1, 65535))
|
||||
end
|
||||
|
||||
-- Wraps run_inner with LC-reset-on-error
|
||||
local function run(pos, event)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local code = meta:get_string("code")
|
||||
local ok, errmsg, retval = run_inner(pos, code, event)
|
||||
if not ok then
|
||||
@ -705,7 +707,7 @@ local function reset(pos)
|
||||
end
|
||||
|
||||
local function node_timer(pos)
|
||||
if minetest.registered_nodes[minetest.get_node(pos).name].is_burnt then
|
||||
if core.registered_nodes[core.get_node(pos).name].is_burnt then
|
||||
return false
|
||||
end
|
||||
run(pos, {type="interrupt"})
|
||||
@ -718,16 +720,16 @@ end
|
||||
|
||||
mesecon.queue:add_function("pipeworks:lc_tube_interrupt", function (pos, luac_id, iid)
|
||||
-- There is no lua_tube anymore / it has been reprogrammed / replaced / burnt
|
||||
if (minetest.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
|
||||
if (minetest.registered_nodes[minetest.get_node(pos).name].is_burnt) then return end
|
||||
if (core.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
|
||||
if (core.registered_nodes[core.get_node(pos).name].is_burnt) then return end
|
||||
run(pos, {type="interrupt", iid = iid})
|
||||
end)
|
||||
|
||||
mesecon.queue:add_function("pipeworks:lt_digiline_relay", function (pos, channel, luac_id, msg)
|
||||
if not digilines then return end
|
||||
if not has_digilines then return end
|
||||
-- This check is only really necessary because in case of server crash, old actions can be thrown into the future
|
||||
if (minetest.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
|
||||
if (minetest.registered_nodes[minetest.get_node(pos).name].is_burnt) then return end
|
||||
if (core.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
|
||||
if (core.registered_nodes[core.get_node(pos).name].is_burnt) then return end
|
||||
-- The actual work
|
||||
digilines.receptor_send(pos, digiline_rules_luatube, channel, msg)
|
||||
end)
|
||||
@ -770,7 +772,7 @@ local digiline = {
|
||||
}
|
||||
|
||||
local function get_program(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
return meta:get_string("code")
|
||||
end
|
||||
|
||||
@ -785,14 +787,14 @@ local function on_receive_fields(pos, form_name, fields, sender)
|
||||
return
|
||||
end
|
||||
local name = sender:get_player_name()
|
||||
if minetest.is_protected(pos, name) and not minetest.check_player_privs(name, {protection_bypass=true}) then
|
||||
minetest.record_protection_violation(pos, name)
|
||||
if core.is_protected(pos, name) and not core.check_player_privs(name, {protection_bypass=true}) then
|
||||
core.record_protection_violation(pos, name)
|
||||
return
|
||||
end
|
||||
local ok, err = set_program(pos, fields.code)
|
||||
if not ok then
|
||||
-- it's not an error from the server perspective
|
||||
minetest.log("action", "Lua controller programming error: " .. tostring(err))
|
||||
core.log("action", "Lua controller programming error: " .. tostring(err))
|
||||
end
|
||||
end
|
||||
|
||||
@ -826,7 +828,7 @@ local tiles_on_off = {
|
||||
R270 = "^(pipeworks_lua_tube_port_%s.png^[transformR270)"
|
||||
}
|
||||
|
||||
local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes
|
||||
local texture_alpha_mode = core.features.use_texture_alpha_string_modes
|
||||
and "clip" or true
|
||||
|
||||
for red = 0, 1 do -- 0 = off 1 = on
|
||||
@ -909,7 +911,7 @@ for white = 0, 1 do
|
||||
},
|
||||
}
|
||||
|
||||
minetest.register_node(node_name, {
|
||||
core.register_node(node_name, {
|
||||
description = "Lua controlled Tube",
|
||||
drawtype = "nodebox",
|
||||
tiles = tiles,
|
||||
@ -997,10 +999,10 @@ for white = 0, 1 do
|
||||
after_place_node = pipeworks.after_place,
|
||||
on_blast = function(pos, intensity)
|
||||
if not intensity or intensity > 1 + 3^0.5 then
|
||||
minetest.remove_node(pos)
|
||||
core.remove_node(pos)
|
||||
return
|
||||
end
|
||||
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
|
||||
core.swap_node(pos, {name = "pipeworks:broken_tube_1"})
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end,
|
||||
})
|
||||
@ -1043,7 +1045,7 @@ tiles_burnt[2] = tiles_burnt[2].."^(pipeworks_lua_tube_port_burnt.png^[transform
|
||||
tiles_burnt[3] = tiles_burnt[3].."^(pipeworks_lua_tube_port_burnt.png^[transformR270)"
|
||||
tiles_burnt[4] = tiles_burnt[4].."^(pipeworks_lua_tube_port_burnt.png^[transformR90)"
|
||||
|
||||
minetest.register_node(BASENAME .. "_burnt", {
|
||||
core.register_node(BASENAME .. "_burnt", {
|
||||
drawtype = "nodebox",
|
||||
tiles = tiles_burnt,
|
||||
use_texture_alpha = texture_alpha_mode,
|
||||
@ -1080,10 +1082,10 @@ minetest.register_node(BASENAME .. "_burnt", {
|
||||
after_dig_node = pipeworks.after_dig,
|
||||
on_blast = function(pos, intensity)
|
||||
if not intensity or intensity > 1 + 3^0.5 then
|
||||
minetest.remove_node(pos)
|
||||
core.remove_node(pos)
|
||||
return
|
||||
end
|
||||
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
|
||||
core.swap_node(pos, {name = "pipeworks:broken_tube_1"})
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end,
|
||||
})
|
||||
@ -1092,7 +1094,7 @@ minetest.register_node(BASENAME .. "_burnt", {
|
||||
-- Craft Registration --
|
||||
------------------------
|
||||
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
type = "shapeless",
|
||||
output = BASENAME.."000000",
|
||||
recipe = {"pipeworks:mese_tube_000000", "mesecons_luacontroller:luacontroller0000"},
|
||||
|
@ -1,4 +1,4 @@
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
local S = core.get_translator("pipeworks")
|
||||
|
||||
local straight = function(pos, node, velocity, stack) return {velocity} end
|
||||
|
||||
@ -10,10 +10,10 @@ local pane_box = {
|
||||
}
|
||||
}
|
||||
|
||||
local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes
|
||||
local texture_alpha_mode = core.features.use_texture_alpha_string_modes
|
||||
and "clip" or true
|
||||
|
||||
minetest.register_node("pipeworks:steel_pane_embedded_tube", {
|
||||
core.register_node("pipeworks:steel_pane_embedded_tube", {
|
||||
drawtype = "nodebox",
|
||||
description = S("Airtight panel embedded tube"),
|
||||
tiles = {
|
||||
@ -42,7 +42,7 @@ minetest.register_node("pipeworks:steel_pane_embedded_tube", {
|
||||
priority = 50,
|
||||
can_go = straight,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local dir = minetest.facedir_to_dir(node.param2)
|
||||
local dir = core.facedir_to_dir(node.param2)
|
||||
return vector.equals(dir, direction) or vector.equals(vector.multiply(dir, -1), direction)
|
||||
end,
|
||||
},
|
||||
|
@ -1,10 +1,10 @@
|
||||
-- This file supplies the various kinds of pneumatic tubes
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
local S = core.get_translator("pipeworks")
|
||||
|
||||
local tubenodes = {}
|
||||
pipeworks.tubenodes = tubenodes
|
||||
|
||||
minetest.register_alias("pipeworks:tube", "pipeworks:tube_000000")
|
||||
core.register_alias("pipeworks:tube", "pipeworks:tube_000000")
|
||||
|
||||
-- now, a function to define the tubes
|
||||
|
||||
@ -27,8 +27,8 @@ local texture_mt = {
|
||||
}
|
||||
|
||||
-- This will remove any semi-transparent pixels
|
||||
-- because that is still buggy in Minetest, force this as default
|
||||
local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes
|
||||
-- because that is still buggy in Luanti, force this as default
|
||||
local texture_alpha_mode = core.features.use_texture_alpha_string_modes
|
||||
and "clip" or true
|
||||
|
||||
local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, ends, short, inv, special, connects, style)
|
||||
@ -122,25 +122,25 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
|
||||
},
|
||||
on_punch = function(pos, node, player, pointed)
|
||||
local playername = player:get_player_name()
|
||||
if minetest.is_protected(pos, playername) and not minetest.check_player_privs(playername, {protection_bypass=true}) then
|
||||
return minetest.node_punch(pos, node, player, pointed)
|
||||
if core.is_protected(pos, playername) and not core.check_player_privs(playername, {protection_bypass=true}) then
|
||||
return core.node_punch(pos, node, player, pointed)
|
||||
end
|
||||
if pipeworks.check_and_wear_hammer(player) then
|
||||
local wieldname = player:get_wielded_item():get_name()
|
||||
pipeworks.logger(string.format("%s struck a tube at %s with %s to break it.", playername, minetest.pos_to_string(pos), wieldname))
|
||||
pipeworks.logger(string.format("%s struck a tube at %s with %s to break it.", playername, core.pos_to_string(pos), wieldname))
|
||||
pipeworks.break_tube(pos)
|
||||
end
|
||||
return minetest.node_punch(pos, node, player, pointed)
|
||||
return core.node_punch(pos, node, player, pointed)
|
||||
end,
|
||||
after_place_node = pipeworks.after_place,
|
||||
after_dig_node = pipeworks.after_dig,
|
||||
on_rotate = false,
|
||||
on_blast = function(pos, intensity)
|
||||
if not intensity or intensity > 1 + 3^0.5 then
|
||||
minetest.remove_node(pos)
|
||||
core.remove_node(pos)
|
||||
return {string.format("%s_%s", name, dropname)}
|
||||
end
|
||||
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
|
||||
core.swap_node(pos, {name = "pipeworks:broken_tube_1"})
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end,
|
||||
check_for_pole = pipeworks.check_for_vert_tube,
|
||||
@ -169,7 +169,7 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node(rname, nodedef)
|
||||
core.register_node(rname, nodedef)
|
||||
end
|
||||
|
||||
local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv, special, old_registration)
|
||||
@ -216,7 +216,7 @@ local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv,
|
||||
end
|
||||
if REGISTER_COMPATIBILITY then
|
||||
local cname = name.."_compatibility"
|
||||
minetest.register_node(cname, {
|
||||
core.register_node(cname, {
|
||||
drawtype = "airlike",
|
||||
style = "6d",
|
||||
basename = name,
|
||||
@ -240,7 +240,7 @@ local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv,
|
||||
for zm = 0, 1 do
|
||||
for zp = 0, 1 do
|
||||
local tname = xm..xp..ym..yp..zm..zp
|
||||
minetest.register_alias(name.."_"..tname, cname)
|
||||
core.register_alias(name.."_"..tname, cname)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -266,14 +266,14 @@ end
|
||||
|
||||
|
||||
if REGISTER_COMPATIBILITY then
|
||||
minetest.register_abm({
|
||||
core.register_abm({
|
||||
nodenames = {"group:tube_to_update"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local minp = vector.subtract(pos, 1)
|
||||
local maxp = vector.add(pos, 1)
|
||||
if table.getn(minetest.find_nodes_in_area(minp, maxp, "ignore")) == 0 then
|
||||
if table.getn(core.find_nodes_in_area(minp, maxp, "ignore")) == 0 then
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,7 @@
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
local S = core.get_translator("pipeworks")
|
||||
-- the default tube and default textures
|
||||
pipeworks.register_tube("pipeworks:tube", S("Pneumatic tube segment"))
|
||||
minetest.register_craft( {
|
||||
core.register_craft( {
|
||||
output = "pipeworks:tube_1 6",
|
||||
recipe = {
|
||||
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
|
||||
@ -53,7 +53,7 @@ pipeworks.register_tube("pipeworks:broken_tube", {
|
||||
is_ground_content = false,
|
||||
tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
minetest.item_drop(stack, nil, pos)
|
||||
core.item_drop(stack, nil, pos)
|
||||
return ItemStack("")
|
||||
end,
|
||||
can_insert = function(pos,node,stack,direction)
|
||||
@ -65,9 +65,9 @@ pipeworks.register_tube("pipeworks:broken_tube", {
|
||||
local itemstack = puncher:get_wielded_item()
|
||||
local wieldname = itemstack:get_name()
|
||||
local playername = puncher:get_player_name()
|
||||
local log_msg = playername.." struck a broken tube at "..minetest.pos_to_string(pos).."\n "
|
||||
local meta = minetest.get_meta(pos)
|
||||
local was_node = minetest.deserialize(meta:get_string("the_tube_was"))
|
||||
local log_msg = playername.." struck a broken tube at "..core.pos_to_string(pos).."\n "
|
||||
local meta = core.get_meta(pos)
|
||||
local was_node = core.deserialize(meta:get_string("the_tube_was"))
|
||||
if not was_node then
|
||||
pipeworks.logger(log_msg.."but it can't be repaired.")
|
||||
return
|
||||
@ -75,8 +75,8 @@ pipeworks.register_tube("pipeworks:broken_tube", {
|
||||
if not pipeworks.check_and_wear_hammer(puncher) then
|
||||
if wieldname == "" then
|
||||
pipeworks.logger(log_msg.."by hand. It's not very effective.")
|
||||
if minetest.settings:get_bool("enable_damage") then
|
||||
minetest.chat_send_player(playername,S("Broken tubes may be a bit sharp. Perhaps try with a hammer?"))
|
||||
if core.settings:get_bool("enable_damage") then
|
||||
core.chat_send_player(playername,S("Broken tubes may be a bit sharp. Perhaps try with a hammer?"))
|
||||
puncher:set_hp(puncher:get_hp()-1)
|
||||
end
|
||||
else
|
||||
@ -85,19 +85,19 @@ pipeworks.register_tube("pipeworks:broken_tube", {
|
||||
return
|
||||
end
|
||||
log_msg = log_msg.."with "..wieldname.." to repair it"
|
||||
local nodedef = minetest.registered_nodes[was_node.name]
|
||||
local nodedef = core.registered_nodes[was_node.name]
|
||||
if nodedef then
|
||||
pipeworks.logger(log_msg..".")
|
||||
if nodedef.tube and nodedef.tube.on_repair then
|
||||
nodedef.tube.on_repair(pos, was_node)
|
||||
else
|
||||
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)
|
||||
end
|
||||
meta:set_string("the_tube_was", "")
|
||||
else
|
||||
pipeworks.logger(log_msg.." but original node "..was_node.name.." is not registered anymore.")
|
||||
minetest.chat_send_player(playername, S("This tube cannot be repaired."))
|
||||
core.chat_send_player(playername, S("This tube cannot be repaired."))
|
||||
end
|
||||
end,
|
||||
allow_metadata_inventory_put = function()
|
||||
@ -161,7 +161,7 @@ if pipeworks.enable_crossing_tube then
|
||||
})
|
||||
end
|
||||
|
||||
local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes
|
||||
local texture_alpha_mode = core.features.use_texture_alpha_string_modes
|
||||
and "clip" or true
|
||||
|
||||
if pipeworks.enable_one_way_tube then
|
||||
@ -170,7 +170,7 @@ if pipeworks.enable_one_way_tube then
|
||||
for i, tile in ipairs(tiles) do
|
||||
tiles[i] = pipeworks.make_tube_tile(tile)
|
||||
end
|
||||
minetest.register_node("pipeworks:one_way_tube", {
|
||||
core.register_node("pipeworks:one_way_tube", {
|
||||
description = S("One way tube"),
|
||||
tiles = tiles,
|
||||
use_texture_alpha = texture_alpha_mode,
|
||||
|
@ -1,51 +1,51 @@
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
local S = core.get_translator("pipeworks")
|
||||
|
||||
-- the minetest.after() calls below can sometimes trigger after a tube
|
||||
-- the core.after() calls below can sometimes trigger after a tube
|
||||
-- breaks, at which point item_exit() is no longer valid, so we have to make
|
||||
-- sure that there even IS a callback to run, first.
|
||||
|
||||
local function after_break(pos)
|
||||
local name = minetest.get_node(pos).name
|
||||
if minetest.registered_nodes[name].item_exit then
|
||||
minetest.registered_nodes[name].item_exit(pos)
|
||||
local name = core.get_node(pos).name
|
||||
if core.registered_nodes[name].item_exit then
|
||||
core.registered_nodes[name].item_exit(pos)
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("mesecons") and pipeworks.enable_detector_tube then
|
||||
local detector_tube_step = 5 * (tonumber(minetest.settings:get("dedicated_server_step")) or 0.09)
|
||||
if core.get_modpath("mesecons") and pipeworks.enable_detector_tube then
|
||||
local detector_tube_step = 5 * (tonumber(core.settings:get("dedicated_server_step")) or 0.09)
|
||||
pipeworks.register_tube("pipeworks:detector_tube_on", {
|
||||
description = S("Detecting Pneumatic Tube Segment on"),
|
||||
inventory_image = "pipeworks_detector_tube_inv.png",
|
||||
plain = { "pipeworks_detector_tube_plain.png" },
|
||||
node_def = {
|
||||
tube = {can_go = function(pos, node, velocity, stack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local nitems = meta:get_int("nitems")+1
|
||||
meta:set_int("nitems", nitems)
|
||||
local saved_pos = vector.new(pos)
|
||||
minetest.after(detector_tube_step, after_break, saved_pos)
|
||||
core.after(detector_tube_step, after_break, saved_pos)
|
||||
return pipeworks.notvel(pipeworks.meseadjlist,velocity)
|
||||
end},
|
||||
groups = {mesecon = 2, not_in_creative_inventory = 1},
|
||||
drop = "pipeworks:detector_tube_off_1",
|
||||
mesecons = {receptor = {state = "on", rules = pipeworks.mesecons_rules}},
|
||||
item_exit = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local nitems = meta:get_int("nitems")-1
|
||||
local node = minetest.get_node(pos)
|
||||
local node = core.get_node(pos)
|
||||
local name = node.name
|
||||
local fdir = node.param2
|
||||
if nitems == 0 then
|
||||
minetest.set_node(pos, {name = string.gsub(name, "on", "off"), param2 = fdir})
|
||||
core.set_node(pos, {name = string.gsub(name, "on", "off"), param2 = fdir})
|
||||
mesecon.receptor_off(pos, pipeworks.mesecons_rules)
|
||||
else
|
||||
meta:set_int("nitems", nitems)
|
||||
end
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
meta:set_int("nitems", 1)
|
||||
minetest.after(detector_tube_step, after_break, pos)
|
||||
core.after(detector_tube_step, after_break, pos)
|
||||
end,
|
||||
},
|
||||
})
|
||||
@ -55,10 +55,10 @@ if minetest.get_modpath("mesecons") and pipeworks.enable_detector_tube then
|
||||
plain = { "pipeworks_detector_tube_plain.png" },
|
||||
node_def = {
|
||||
tube = {can_go = function(pos, node, velocity, stack)
|
||||
local node = minetest.get_node(pos)
|
||||
local node = core.get_node(pos)
|
||||
local name = node.name
|
||||
local fdir = node.param2
|
||||
minetest.set_node(pos,{name = string.gsub(name, "off", "on"), param2 = fdir})
|
||||
core.set_node(pos,{name = string.gsub(name, "off", "on"), param2 = fdir})
|
||||
mesecon.receptor_on(pos, pipeworks.mesecons_rules)
|
||||
return pipeworks.notvel(pipeworks.meseadjlist, velocity)
|
||||
end},
|
||||
@ -67,7 +67,7 @@ if minetest.get_modpath("mesecons") and pipeworks.enable_detector_tube then
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
core.register_craft( {
|
||||
output = "pipeworks:detector_tube_off_1 2",
|
||||
recipe = {
|
||||
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
|
||||
@ -77,7 +77,7 @@ if minetest.get_modpath("mesecons") and pipeworks.enable_detector_tube then
|
||||
})
|
||||
end
|
||||
|
||||
local digiline_enabled = minetest.get_modpath("digilines") ~= nil
|
||||
local digiline_enabled = core.get_modpath("digilines") ~= nil
|
||||
if digiline_enabled and pipeworks.enable_digiline_detector_tube then
|
||||
pipeworks.register_tube("pipeworks:digiline_detector_tube", {
|
||||
description = S("Digiline Detecting Pneumatic Tube Segment"),
|
||||
@ -85,7 +85,7 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
|
||||
plain = { "pipeworks_digiline_detector_tube_plain.png" },
|
||||
node_def = {
|
||||
tube = {can_go = function(pos, node, velocity, stack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
|
||||
local setchan = meta:get_string("channel")
|
||||
|
||||
@ -94,7 +94,7 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
|
||||
return pipeworks.notvel(pipeworks.meseadjlist, velocity)
|
||||
end},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"size[8.5,2.2]"..
|
||||
"image[0.2,0;1,1;pipeworks_digiline_detector_tube_inv.png]"..
|
||||
@ -111,7 +111,7 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
|
||||
return
|
||||
end
|
||||
if fields.channel then
|
||||
minetest.get_meta(pos):set_string("channel", fields.channel)
|
||||
core.get_meta(pos):set_string("channel", fields.channel)
|
||||
end
|
||||
end,
|
||||
groups = {},
|
||||
@ -127,7 +127,7 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
core.register_craft( {
|
||||
output = "pipeworks:digiline_detector_tube_1 2",
|
||||
recipe = {
|
||||
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
|
||||
@ -137,7 +137,7 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
|
||||
})
|
||||
end
|
||||
|
||||
if minetest.get_modpath("mesecons") and pipeworks.enable_conductor_tube then
|
||||
if core.get_modpath("mesecons") and pipeworks.enable_conductor_tube then
|
||||
pipeworks.register_tube("pipeworks:conductor_tube_off", {
|
||||
description = S("Conducting Pneumatic Tube Segment"),
|
||||
inventory_image = "pipeworks_conductor_tube_inv.png",
|
||||
@ -168,7 +168,7 @@ if minetest.get_modpath("mesecons") and pipeworks.enable_conductor_tube then
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
type = "shapeless",
|
||||
output = "pipeworks:conductor_tube_off_1",
|
||||
recipe = {"pipeworks:tube_1", "mesecons:mesecon"}
|
||||
@ -185,7 +185,7 @@ if digiline_enabled and pipeworks.enable_digiline_conductor_tube then
|
||||
ends = {"pipeworks_tube_end.png^pipeworks_digiline_conductor_tube_end.png"},
|
||||
node_def = {digilines = {wire = {rules = pipeworks.digilines_rules}}},
|
||||
})
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
type = "shapeless",
|
||||
output = "pipeworks:digiline_conductor_tube_1",
|
||||
recipe = {"pipeworks:tube_1", "digilines:wire_std_00000000"}
|
||||
@ -229,17 +229,17 @@ if digiline_enabled and pipeworks.enable_digiline_conductor_tube and
|
||||
},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
type = "shapeless",
|
||||
output = "pipeworks:mesecon_and_digiline_conductor_tube_off_1",
|
||||
recipe = {"pipeworks:tube_1", "mesecons:mesecon", "digilines:wire_std_00000000"}
|
||||
})
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
type = "shapeless",
|
||||
output = "pipeworks:mesecon_and_digiline_conductor_tube_off_1",
|
||||
recipe = {"pipeworks:conductor_tube_off_1", "digilines:wire_std_00000000"}
|
||||
})
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
type = "shapeless",
|
||||
output = "pipeworks:mesecon_and_digiline_conductor_tube_off_1",
|
||||
recipe = {"pipeworks:digiline_conductor_tube_1", "mesecons:mesecon"}
|
||||
|
@ -1,15 +1,15 @@
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
local S = core.get_translator("pipeworks")
|
||||
local fs_helpers = pipeworks.fs_helpers
|
||||
|
||||
if pipeworks.enable_mese_tube then
|
||||
local function update_formspec(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local old_formspec = meta:get_string("formspec")
|
||||
if string.find(old_formspec, "button1") then -- Old version
|
||||
local inv = meta:get_inventory()
|
||||
for i = 1, 6 do
|
||||
for _, stack in ipairs(inv:get_list("line"..i)) do
|
||||
minetest.add_item(pos, stack)
|
||||
core.add_item(pos, stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -24,7 +24,7 @@ if pipeworks.enable_mese_tube then
|
||||
)
|
||||
end
|
||||
local list_backgrounds = ""
|
||||
if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then
|
||||
if core.get_modpath("i3") or core.get_modpath("mcl_formspec") then
|
||||
list_backgrounds = "style_type[box;colors=#666]"
|
||||
for i=0, 5 do
|
||||
for j=0, 5 do
|
||||
@ -83,13 +83,13 @@ if pipeworks.enable_mese_tube then
|
||||
tube = {can_go = function(pos, node, velocity, stack)
|
||||
local tbl, tbln = {}, 0
|
||||
local found, foundn = {}, 0
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local name = stack:get_name()
|
||||
for i, vect in ipairs(pipeworks.meseadjlist) do
|
||||
local npos = vector.add(pos, vect)
|
||||
local node = minetest.get_node(npos)
|
||||
local reg_node = minetest.registered_nodes[node.name]
|
||||
local node = core.get_node(npos)
|
||||
local reg_node = core.registered_nodes[node.name]
|
||||
if meta:get_int("l"..i.."s") == 1 and reg_node then
|
||||
local tube_def = reg_node.tube
|
||||
if not tube_def or not tube_def.can_insert or
|
||||
@ -115,7 +115,7 @@ if pipeworks.enable_mese_tube then
|
||||
return (foundn > 0) and found or tbl
|
||||
end},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
for i = 1, 6 do
|
||||
meta:set_int("l"..tostring(i).."s", 1)
|
||||
@ -126,7 +126,7 @@ if pipeworks.enable_mese_tube then
|
||||
end,
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
if placer and placer:is_player() and placer:get_player_control().aux1 then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
for i = 1, 6 do
|
||||
meta:set_int("l"..tostring(i).."s", 0)
|
||||
end
|
||||
@ -150,7 +150,7 @@ if pipeworks.enable_mese_tube then
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
if not pipeworks.may_configure(pos, player) then return 0 end
|
||||
update_formspec(pos) -- For old tubes
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
local inv = core.get_meta(pos):get_inventory()
|
||||
local stack_copy = ItemStack(stack)
|
||||
stack_copy:set_count(1)
|
||||
inv:set_stack(listname, index, stack_copy)
|
||||
@ -159,14 +159,14 @@ if pipeworks.enable_mese_tube then
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
if not pipeworks.may_configure(pos, player) then return 0 end
|
||||
update_formspec(pos) -- For old tubes
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
local inv = core.get_meta(pos):get_inventory()
|
||||
inv:set_stack(listname, index, ItemStack(""))
|
||||
return 0
|
||||
end,
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
if not pipeworks.may_configure(pos, player) then return 0 end
|
||||
update_formspec(pos) -- For old tubes
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
local inv = core.get_meta(pos):get_inventory()
|
||||
|
||||
if from_list:match("line%d") and to_list:match("line%d") then
|
||||
return count
|
||||
|
@ -1,15 +1,15 @@
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
local S = core.get_translator("pipeworks")
|
||||
local fs_helpers = pipeworks.fs_helpers
|
||||
|
||||
if not pipeworks.enable_item_tags or not pipeworks.enable_tag_tube then return end
|
||||
|
||||
local help_text = minetest.formspec_escape(
|
||||
local help_text = core.formspec_escape(
|
||||
S("Separate multiple tags using commas.").."\n"..
|
||||
S("Use \"<none>\" to match items without tags.")
|
||||
)
|
||||
|
||||
local update_formspec = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local buttons_formspec = ""
|
||||
for i = 0, 5 do
|
||||
buttons_formspec = buttons_formspec .. fs_helpers.cycling_button(meta,
|
||||
@ -59,7 +59,7 @@ pipeworks.register_tube("pipeworks:tag_tube", {
|
||||
can_go = function(pos, node, velocity, stack, tags)
|
||||
local tbl, tbln = {}, 0
|
||||
local found, foundn = {}, 0
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local tag_hash = {}
|
||||
if #tags > 0 then
|
||||
for _,tag in ipairs(tags) do
|
||||
@ -70,8 +70,8 @@ pipeworks.register_tube("pipeworks:tag_tube", {
|
||||
end
|
||||
for i, vect in ipairs(pipeworks.meseadjlist) do
|
||||
local npos = vector.add(pos, vect)
|
||||
local node = minetest.get_node(npos)
|
||||
local reg_node = minetest.registered_nodes[node.name]
|
||||
local node = core.get_node(npos)
|
||||
local reg_node = core.registered_nodes[node.name]
|
||||
if meta:get_int("l" .. i .. "s") == 1 and reg_node then
|
||||
local tube_def = reg_node.tube
|
||||
if not tube_def or not tube_def.can_insert or
|
||||
@ -97,7 +97,7 @@ pipeworks.register_tube("pipeworks:tag_tube", {
|
||||
end
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
for i = 1, 6 do
|
||||
meta:set_int("l" .. tostring(i) .. "s", 1)
|
||||
end
|
||||
@ -106,7 +106,7 @@ pipeworks.register_tube("pipeworks:tag_tube", {
|
||||
end,
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
if placer and placer:is_player() and placer:get_player_control().aux1 then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
for i = 1, 6 do
|
||||
meta:set_int("l" .. tostring(i) .. "s", 0)
|
||||
end
|
||||
@ -120,7 +120,7 @@ pipeworks.register_tube("pipeworks:tag_tube", {
|
||||
return
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
for i = 1, 6 do
|
||||
local field_name = "tags" .. tostring(i)
|
||||
if fields[field_name] then
|
||||
|
@ -1,11 +1,11 @@
|
||||
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
local filename = minetest.get_worldpath().."/teleport_tubes" -- Only used for backward-compat
|
||||
local storage = minetest.get_mod_storage()
|
||||
local S = core.get_translator("pipeworks")
|
||||
local filename = core.get_worldpath().."/teleport_tubes" -- Only used for backward-compat
|
||||
local storage = core.get_mod_storage()
|
||||
|
||||
local enable_logging = minetest.settings:get_bool("pipeworks_log_teleport_tubes", false)
|
||||
local enable_logging = core.settings:get_bool("pipeworks_log_teleport_tubes", false)
|
||||
|
||||
local has_digilines = minetest.get_modpath("digilines")
|
||||
local has_digilines = core.get_modpath("digilines")
|
||||
|
||||
-- V1: Serialized text file indexed by vector position.
|
||||
-- V2: Serialized text file indexed by hash position.
|
||||
@ -17,7 +17,7 @@ local receiver_cache = {}
|
||||
|
||||
local function hash_pos(pos)
|
||||
vector.round(pos)
|
||||
return string.format("%.0f", minetest.hash_node_position(pos))
|
||||
return string.format("%.0f", core.hash_node_position(pos))
|
||||
end
|
||||
|
||||
local function serialize_tube(tube)
|
||||
@ -29,7 +29,7 @@ local function deserialize_tube(hash, str)
|
||||
local cr = tonumber(str:sub(1, 1))
|
||||
local channel = str:sub(3)
|
||||
if sep and cr and channel then
|
||||
local pos = minetest.get_position_from_hash(tonumber(hash))
|
||||
local pos = core.get_position_from_hash(tonumber(hash))
|
||||
return {x = pos.x, y = pos.y, z = pos.z, cr = cr, channel = channel}
|
||||
end
|
||||
end
|
||||
@ -62,7 +62,7 @@ local function migrate_tube_db()
|
||||
if storage:get_int("version") == 3 then
|
||||
for key, val in pairs(storage:to_table().fields) do
|
||||
if tonumber(key) then
|
||||
tube_db[key] = minetest.deserialize(val)
|
||||
tube_db[key] = core.deserialize(val)
|
||||
elseif key ~= "version" then
|
||||
error("Unknown field in teleport tube database: "..key)
|
||||
end
|
||||
@ -75,7 +75,7 @@ local function migrate_tube_db()
|
||||
local content = file:read("*all")
|
||||
io.close(file)
|
||||
if content and content ~= "" then
|
||||
tube_db = minetest.deserialize(content)
|
||||
tube_db = core.deserialize(content)
|
||||
end
|
||||
end
|
||||
local version = tube_db.version or 0
|
||||
@ -134,8 +134,8 @@ local function get_receivers(pos, channel)
|
||||
local receivers = {}
|
||||
for key, val in pairs(tube_db) do
|
||||
if val.cr == 1 and val.channel == channel and not vector.equals(val, pos) then
|
||||
minetest.load_area(val)
|
||||
local node_name = minetest.get_node(val).name
|
||||
core.load_area(val)
|
||||
local node_name = core.get_node(val).name
|
||||
if node_name:find("pipeworks:teleport_tube") then
|
||||
table.insert(receivers, val)
|
||||
else
|
||||
@ -148,7 +148,7 @@ local function get_receivers(pos, channel)
|
||||
return receivers
|
||||
end
|
||||
|
||||
local help_text = minetest.formspec_escape(
|
||||
local help_text = core.formspec_escape(
|
||||
S("Channels are public by default").."\n"..
|
||||
S("Use <player>:<channel> for fully private channels").."\n"..
|
||||
S("Use <player>;<channel> for private receivers")
|
||||
@ -187,7 +187,7 @@ local function update_meta(meta)
|
||||
end
|
||||
|
||||
local function update_tube(pos, channel, cr, player_name)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
if meta:get_string("channel") == channel and meta:get_int("can_receive") == cr then
|
||||
return
|
||||
end
|
||||
@ -200,11 +200,11 @@ local function update_tube(pos, channel, cr, player_name)
|
||||
local name, mode = channel:match("^([^:;]+)([:;])")
|
||||
if name and mode and name ~= player_name then
|
||||
if mode == ":" then
|
||||
minetest.chat_send_player(player_name,
|
||||
core.chat_send_player(player_name,
|
||||
S("Sorry, channel '@1' is reserved for exclusive use by @2", channel, name))
|
||||
return
|
||||
elseif mode == ";" and cr ~= 0 then
|
||||
minetest.chat_send_player(player_name,
|
||||
core.chat_send_player(player_name,
|
||||
S("Sorry, receiving from channel '@1' is reserved for @2", channel, name))
|
||||
return
|
||||
end
|
||||
@ -218,7 +218,7 @@ local function receive_fields(pos, _, fields, sender)
|
||||
if not fields.channel or not pipeworks.may_configure(pos, sender) then
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local channel = fields.channel:trim()
|
||||
local cr = meta:get_int("can_receive")
|
||||
if fields.cr_on then
|
||||
@ -237,7 +237,7 @@ local function can_go(pos, node, velocity, stack)
|
||||
velocity.x = 0
|
||||
velocity.y = 0
|
||||
velocity.z = 0
|
||||
local src_meta = minetest.get_meta(pos)
|
||||
local src_meta = core.get_meta(pos)
|
||||
local channel = src_meta:get_string("channel")
|
||||
if channel == "" then
|
||||
return {}
|
||||
@ -249,10 +249,10 @@ local function can_go(pos, node, velocity, stack)
|
||||
local target = receivers[math.random(1, #receivers)]
|
||||
if enable_logging then
|
||||
local src_owner = src_meta:get_string("owner")
|
||||
local dst_meta = minetest.get_meta(pos)
|
||||
local dst_meta = core.get_meta(pos)
|
||||
local dst_owner = dst_meta:get_string("owner")
|
||||
minetest.log("action", string.format("[pipeworks] %s teleported from %s (owner=%s) to %s (owner=%s) via %s",
|
||||
stack:to_string(), minetest.pos_to_string(pos), src_owner, minetest.pos_to_string(target), dst_owner, channel
|
||||
core.log("action", string.format("[pipeworks] %s teleported from %s (owner=%s) to %s (owner=%s) via %s",
|
||||
stack:to_string(), core.pos_to_string(pos), src_owner, core.pos_to_string(target), dst_owner, channel
|
||||
))
|
||||
end
|
||||
pos.x = target.x
|
||||
@ -262,9 +262,9 @@ local function can_go(pos, node, velocity, stack)
|
||||
end
|
||||
|
||||
local function repair_tube(pos, node)
|
||||
minetest.swap_node(pos, {name = node.name, param2 = node.param2})
|
||||
core.swap_node(pos, {name = node.name, param2 = node.param2})
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local channel = meta:get_string("channel")
|
||||
if channel ~= "" then
|
||||
set_tube(pos, channel, meta:get_int("can_receive"))
|
||||
@ -273,7 +273,7 @@ local function repair_tube(pos, node)
|
||||
end
|
||||
|
||||
local function digiline_action(pos, _, digiline_channel, msg)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
if digiline_channel ~= meta:get_string("digiline_channel") then
|
||||
return
|
||||
end
|
||||
@ -304,7 +304,7 @@ local def = {
|
||||
on_repair = repair_tube,
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
meta:set_int("can_receive", 1) -- Enabled by default
|
||||
update_meta(meta)
|
||||
end,
|
||||
@ -315,7 +315,7 @@ local def = {
|
||||
if has_digilines then
|
||||
def.after_place_node = function(pos, placer)
|
||||
-- Set owner for digilines
|
||||
minetest.get_meta(pos):set_string("owner", placer:get_player_name())
|
||||
core.get_meta(pos):set_string("owner", placer:get_player_name())
|
||||
pipeworks.after_place(pos)
|
||||
end
|
||||
def.digilines = {
|
||||
@ -339,12 +339,12 @@ pipeworks.register_tube("pipeworks:teleport_tube", {
|
||||
node_def = def,
|
||||
})
|
||||
|
||||
if minetest.get_modpath("mesecons_mvps") then
|
||||
if core.get_modpath("mesecons_mvps") then
|
||||
-- Update tubes when moved by pistons
|
||||
mesecon.register_on_mvps_move(function(moved_nodes)
|
||||
for _, n in ipairs(moved_nodes) do
|
||||
if n.node.name:find("pipeworks:teleport_tube") then
|
||||
local meta = minetest.get_meta(n.pos)
|
||||
local meta = core.get_meta(n.pos)
|
||||
set_tube(n.pos, meta:get_string("channel"), meta:get_int("can_receive"))
|
||||
end
|
||||
end
|
||||
|
@ -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