Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ read_globals = {
"core",
"table.copy",
"table.indexof",
"string.split",
"minetest",
"ItemStack",
"barter",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ To make maintaining support easier, wrench only supports specific versions of mo
- `technic` - https://github.com/mt-mods/technic OR https://github.com/minetest-mods/technic
- `technic_chests` - https://github.com/mt-mods/technic
- `technic_cnc` - https://github.com/mt-mods/technic
- `telemosaic` - https://github.com/mt-mods/telemosaic
- `vacuum` - https://github.com/mt-mods/vacuum
- `vessels` - https://github.com/minetest/minetest_game
- `wine` - https://codeberg.org/tenplus1/wine
Expand Down
1 change: 1 addition & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ local mods = {
"technic",
"technic_chests",
"technic_cnc",
"telemosaic",
"vacuum",
"vessels",
"wine",
Expand Down
63 changes: 63 additions & 0 deletions nodes/telemosaic.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

local S = wrench.translator

local function get_dest_string(meta)
local dest = meta:get("telemosaic:dest")
if dest and dest:find(":") then
-- Old version
local list = string.split(dest, ':')
local p = {
x = tonumber(list[1]),
y = tonumber(list[2]),
z = tonumber(list[3])
}
if p.x and p.y and p.z then
return core.pos_to_string(p)
end
else
return dest
end
end

local function save_old_pos(pos)
core.get_meta(pos):set_string("old_pos", core.pos_to_string(pos))
end

local function after_place(pos)
local meta = core.get_meta(pos)
local old_pos = meta:get("old_pos")
local dest = get_dest_string(meta)
if not old_pos or not dest then
return
end
local other_meta = core.get_meta(core.string_to_pos(dest))
local other_dest = get_dest_string(other_meta)
if other_dest and old_pos == other_dest then
-- Update the connected telemosaic
other_meta:set_string("telemosaic:dest", core.pos_to_string(pos))
end
meta:set_string("old_pos", "")
end

local function description(pos, meta, node, player)
local suffix = node.name:match("_protected$") and "_protected" or ""
local name = core.registered_nodes["telemosaic:beacon_off"..suffix].description
local dest = get_dest_string(meta) or ""
return S("@1 with destination @2", name, dest)
end

local def = {
metas = {
["telemosaic:dest"] = wrench.META_TYPE_STRING,
channel = core.get_modpath("digilines") and wrench.META_TYPE_STRING or nil,
old_pos = wrench.META_TYPE_STRING, -- Temporary value used to update connected beacons
},
description = description,
after_place = after_place,
can_pickup = save_old_pos,
}

for _,state in ipairs({"", "_disabled", "_err"}) do
wrench.register_node("telemosaic:beacon"..state, def)
wrench.register_node("telemosaic:beacon"..state.."_protected", def)
end