Merge remote-tracking branch 'upstream/master'

This commit is contained in:
bri cassa 2021-04-04 21:02:57 +02:00
commit e4db1e885e
10 changed files with 181 additions and 75 deletions

View File

@ -14,17 +14,20 @@ local function set_filter_formspec(data, meta)
local formspec
if data.digiline then
formspec = "size[8,2.7]"..
"item_image[0,0;1,1;pipeworks:"..data.name.."]"..
"label[1,0;"..minetest.formspec_escape(itemname).."]"..
"field[0.3,1.5;8.0,1;channel;"..S("Channel")..";${channel}]"..
fs_helpers.cycling_button(meta, "button[0,2;4,1", "slotseq_mode",
formspec =
"size[8.5,3]"..
"item_image[0.2,0;1,1;pipeworks:"..data.name.."]"..
"label[1.2,0.2;"..minetest.formspec_escape(itemname).."]"..
"field[0.5,1.6;4.6,1;channel;"..S("Channel")..";${channel}]"..
"button[4.8,1.3;1.5,1;set_channel;"..S("Set").."]"..
fs_helpers.cycling_button(meta, "button[0.2,2.3;4.05,1", "slotseq_mode",
{S("Sequence slots by Priority"),
S("Sequence slots Randomly"),
S("Sequence slots by Rotation")})..
fs_helpers.cycling_button(meta, "button[4,2;4,1", "exmatch_mode",
fs_helpers.cycling_button(meta, "button[4.25,2.3;4.05,1", "exmatch_mode",
{S("Exact match - off"),
S("Exact match - on")})
S("Exact match - on")})..
"button_exit[6.3,1.3;2,1;close;"..S("Close").."]"
else
local exmatch_button = ""
if data.stackwise then
@ -425,10 +428,14 @@ for _, data in ipairs({
end
node.on_receive_fields = function(pos, formname, fields, sender)
if not pipeworks.may_configure(pos, sender) then return end
if (fields.quit and not fields.key_enter_field)
or not pipeworks.may_configure(pos, sender) then
return
end
fs_helpers.on_receive_fields(pos, fields)
if fields.channel then
if fields.channel and (fields.key_enter_field == "channel" or fields.set_channel) then
minetest.get_meta(pos):set_string("channel", fields.channel)
end

View File

@ -55,15 +55,22 @@ end)
-- tube overload mechanism:
-- when the tube's item count (tracked in the above tube_item_count table)
-- exceeds the limit configured per tube, replace it with a broken one.
function pipeworks.break_tube(pos)
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
meta:set_string("the_tube_was", minetest.serialize(node))
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
pipeworks.scan_for_tube_objects(pos)
end
local crunch_tube = function(pos, cnode, cmeta)
if enable_max_limit then
local h = minetest.hash_node_position(pos)
local itemcount = tube_item_count[h] or 0
if itemcount > max_tube_limit then
cmeta:set_string("the_tube_was", minetest.serialize(cnode))
pipeworks.logger("Warning - a tube at "..minetest.pos_to_string(pos).." broke due to too many items ("..itemcount..")")
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
pipeworks.scan_for_tube_objects(pos)
pipeworks.break_tube(pos)
end
end
end

View File

@ -3,6 +3,10 @@
# License: CC-by-SA 4.0
# Author: Louis Royer <4259825-lroyer@users.noreply.gitlab.com>
## generic interaction
Set=Fixer
Close=Fermer
## digilines interfacing
Channel=Canal
@ -86,11 +90,12 @@ Sorting pneumatic tube=Tuyau pneumatique triant
## teleport tube
Receive=Reception
channels are public by default=Les canaux sont publics par défaut
use <player>:<channel> for fully private channels=Utilisez <joueur>:<canal> pour un canal entièrement privé
use <player>;<channel> for private receivers=Utilisez <joueur>;<canal> pour une réception privée
Channels are public by default=Les canaux sont publics par défaut
Use <player>:<channel> for fully private channels=Utilisez <joueur>:<canal> pour un canal entièrement privé
Use <player>;<channel> for private receivers=Utilisez <joueur>;<canal> pour une réception privée
Teleporting Pneumatic Tube Segment=Segment de tuyau pneumatique téléporteur
unconfigured Teleportation Tube=Tuyau téléporteur non-configuré
Teleporting Tube=Tuyau pneumatique téléporteur
Unconfigured Teleportation Tube=Tuyau téléporteur non-configuré
Sorry, channel '@1' is reserved for exclusive use by @2=Désolé, le canal '@1' est réservé exclusivement à lutilisateur @2.
Sorry, receiving from channel '@1' is reserved for @2=Désolé, la réception depuis le canal '@1' est réservée pour @2.
Teleportation Tube @1 on '@2'=Tuyau de téléportation @1 sur '@2'
@ -102,7 +107,9 @@ Trash Can=Poubelle
Pneumatic tube segment (legacy)=Segment de tuyau pneumatique (obsolète)
## vacuum tubes
Radius=Rayon
Vacuuming Pneumatic Tube Segment=Segment de tuyau pneumatique aspirant
Adjustable Vacuuming Tube=Tuyau pneumatique aspirant réglable
Adjustable Vacuuming Pneumatic Tube Segment=Segment de tuyau pneumatique aspirant réglable
Adjustable Vacuuming Pneumatic Tube Segment (@1m)=Segment de tuyau pneumatique aspirant réglable (@1 m)

View File

@ -2,6 +2,10 @@
# License: CC-by-SA 4.0
# Author: pevernow <3450354617@qq.com>
## generic interaction
Set=
Cancel=
## digilines interfacing
Channel=频道
@ -84,11 +88,12 @@ Sorting pneumatic tube=分类管道
## teleport tube
Receive=接收
channels are public by default=频道默认为公开
use <player>:<channel> for fully private channels=将<player>:<channel>用于完全私人的频道
use <player>;<channel> for private receivers=使用<player>;<channel>作为私人接收器
Channels are public by default=频道默认为公开
Use <player>:<channel> for fully private channels=将<player>:<channel>用于完全私人的频道
Use <player>;<channel> for private receivers=使用<player>;<channel>作为私人接收器
Teleporting Pneumatic Tube Segment=传送管道
unconfigured Teleportation Tube=未配置的传送管道
Teleporting Tube=
Unconfigured Teleportation Tube=未配置的传送管道
Sorry, channel '@1' is reserved for exclusive use by @2=抱歉,频道‘@1保留供@2专用
Sorry, receiving from channel '@1' is reserved for @2=抱歉,从频道'@1'接收的内容已保留给'@2'
Teleportation Tube @1 on '@2'=传送管'@1'在'@2'上
@ -100,7 +105,9 @@ Trash Can=垃圾箱
Pneumatic tube segment (legacy)=普通管道(旧式)
## vacuum tubes
Radius=
Vacuuming Pneumatic Tube Segment=拾取管道
Adjustable Vacuuming Tube=
Adjustable Vacuuming Pneumatic Tube Segment=高级拾取管道
Adjustable Vacuuming Pneumatic Tube Segment (@1m)=高级拾取管道(@1m)

View File

@ -3,6 +3,10 @@
# License: CC-by-SA 4.0
# Author:
## generic interaction
Set=
Cancel=
## digilines interfacing
Channel=
@ -86,11 +90,12 @@ Sorting pneumatic tube=
## teleport tube
Receive=
channels are public by default=
use <player>:<channel> for fully private channels=
use <player>;<channel> for private receivers=
Channels are public by default=
Use <player>:<channel> for fully private channels=
Use <player>;<channel> for private receivers=
Teleporting Pneumatic Tube Segment=
unconfigured Teleportation Tube=
Teleporting Tube=
Unconfigured Teleportation Tube=
Sorry, channel '@1' is reserved for exclusive use by @2=
Sorry, receiving from channel '@1' is reserved for @2=
Teleportation Tube @1 on '@2'=
@ -102,7 +107,9 @@ Trash Can=
Pneumatic tube segment (legacy)=
## vacuum tubes
Radius=
Vacuuming Pneumatic Tube Segment=
Adjustable Vacuuming Tube=
Adjustable Vacuuming Pneumatic Tube Segment=
Adjustable Vacuuming Pneumatic Tube Segment (@1m)=

View File

@ -10,6 +10,35 @@ minetest.register_craft( {
},
})
-- The hammers that can be used to break/repair tubes
local allowed_hammers = {
"anvil:hammer",
"cottages:hammer",
"glooptest:hammer_steel",
"glooptest:hammer_bronze",
"glooptest:hammer_diamond",
"glooptest:hammer_mese",
"glooptest:hammer_alatro",
"glooptest:hammer_arol"
}
-- Convert the above list to a format that's easier to look up
for _,hammer in ipairs(allowed_hammers) do
allowed_hammers[hammer] = true
end
-- Check if the player is holding a suitable hammer or not - if they are, apply wear to it
function pipeworks.check_and_wear_hammer(player)
local itemstack = player:get_wielded_item()
local wieldname = itemstack:get_name()
if allowed_hammers[wieldname] then
itemstack:add_wear(1000)
player:set_wielded_item(itemstack)
return true
end
return false
end
local nodecolor = 0xffff3030
pipeworks.register_tube("pipeworks:broken_tube", {
@ -36,29 +65,27 @@ pipeworks.register_tube("pipeworks:broken_tube", {
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"
if wieldname == "anvil:hammer"
or wieldname == "cottages:hammer"
or wieldname == "glooptest:hammer_steel"
or wieldname == "glooptest:hammer_bronze"
or wieldname == "glooptest:hammer_diamond"
or wieldname == "glooptest:hammer_mese"
or wieldname == "glooptest:hammer_alatro"
or wieldname == "glooptest:hammer_arol" then
local meta = minetest.get_meta(pos)
local was_node = minetest.deserialize(meta:get_string("the_tube_was"))
if was_node and was_node ~= "" then
pipeworks.logger(log_msg.." with "..wieldname.." to repair it.")
minetest.swap_node(pos, { name = was_node.name, param2 = was_node.param2 })
pipeworks.scan_for_tube_objects(pos)
itemstack:add_wear(1000)
puncher:set_wielded_item(itemstack)
return itemstack
else
if not was_node then
pipeworks.logger(log_msg.." but it can't be repaired.")
return
end
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?"))
puncher:set_hp(puncher:get_hp()-1)
end
else
pipeworks.logger(log_msg.." with "..wieldname.." but that tool is too weak.")
end
return
end
pipeworks.logger(log_msg.." with "..wieldname.." to repair it.")
minetest.swap_node(pos, { name = was_node.name, param2 = was_node.param2 })
pipeworks.scan_for_tube_objects(pos)
end
}
})

View File

@ -1,4 +1,16 @@
local S = minetest.get_translator("pipeworks")
-- the minetest.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)
end
end
if pipeworks.enable_detector_tube then
local detector_tube_step = 5 * tonumber(minetest.settings:get("dedicated_server_step"))
pipeworks.register_tube("pipeworks:detector_tube_on", {
@ -8,11 +20,10 @@ if pipeworks.enable_detector_tube then
node_def = {
tube = {can_go = function(pos, node, velocity, stack)
local meta = minetest.get_meta(pos)
local name = minetest.get_node(pos).name
local nitems = meta:get_int("nitems")+1
meta:set_int("nitems", nitems)
local saved_pos = vector.new(pos)
minetest.after(detector_tube_step, minetest.registered_nodes[name].item_exit, saved_pos)
minetest.after(detector_tube_step, after_break, saved_pos)
return pipeworks.notvel(pipeworks.meseadjlist,velocity)
end},
groups = {mesecon = 2, not_in_creative_inventory = 1},
@ -34,9 +45,7 @@ if pipeworks.enable_detector_tube then
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_int("nitems", 1)
local name = minetest.get_node(pos).name
local saved_pos = vector.new(pos)
minetest.after(detector_tube_step, minetest.registered_nodes[name].item_exit, saved_pos)
minetest.after(detector_tube_step, after_break, pos)
end,
},
})
@ -87,13 +96,20 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"size[8.6,2.2]"..
"field[0.6,0.6;8,1;channel;"..S("Channel")..";${channel}]"..
"image[0.3,1.3;1,1;pipeworks_digiline_detector_tube_inv.png]"..
"label[1.6,1.2;"..S("Digiline Detecting Tube").."]"
"size[8.5,2.2]"..
"image[0.2,0;1,1;pipeworks_digiline_detector_tube_inv.png]"..
"label[1.2,0.2;"..S("Digiline Detecting Tube").."]"..
"field[0.5,1.6;4.6,1;channel;"..S("Channel")..";${channel}]"..
"button[4.8,1.3;1.5,1;set_channel;"..S("Set").."]"..
"button_exit[6.3,1.3;2,1;close;"..S("Close").."]"
)
end,
on_receive_fields = function(pos, formname, fields, sender)
if (fields.quit and not fields.key_enter_field)
or (fields.key_enter_field ~= "channel" and not fields.set_channel)
or not pipeworks.may_configure(pos, sender) then
return
end
if fields.channel then
minetest.get_meta(pos):set_string("channel", fields.channel)
end

View File

@ -127,14 +127,20 @@ end
local function update_meta(meta, can_receive)
meta:set_int("can_receive", can_receive and 1 or 0)
local cr_state = can_receive and "on" or "off"
meta:set_string("formspec","size[8.6,2.2]"..
"field[0.6,0.6;7,1;channel;"..S("Channel")..";${channel}]"..
"label[7.3,0;"..S("Receive").."]"..
"image_button[7.3,0.3;1,0.6;pipeworks_button_" .. cr_state .. ".png;cr" .. (can_receive and 0 or 1) .. ";;;false;pipeworks_button_interm.png]"..
"image[0.3,1.3;1,1;pipeworks_teleport_tube_inv.png]"..
"label[1.6,1.2;"..S("channels are public by default").."]" ..
"label[1.6,1.5;"..S("use <player>:<channel> for fully private channels").."]" ..
"label[1.6,1.8;"..S("use <player>\\;<channel> for private receivers").."]" ..
local itext = S("Channels are public by default").."\n"..
S("Use <player>:<channel> for fully private channels").."\n"..
S("Use <player>\\;<channel> for private receivers")
meta:set_string("formspec",
"size[8.5,3.5]"..
"image[0.2,o;1,1;pipeworks_teleport_tube_inv.png]"..
"label[1.2,0.2;"..S("Teleporting Tube").."]"..
"field[0.5,1.6;4.6,1;channel;"..S("Channel")..";${channel}]"..
"button[4.8,1.3;1.5,1;set_channel;"..S("Set").."]"..
"label[7.0,0;"..S("Receive").."]"..
"image_button[7.0,0.5;1,0.6;pipeworks_button_" .. cr_state .. ".png;cr" .. (can_receive and 0 or 1) .. ";;;false;pipeworks_button_interm.png]"..
"button_exit[6.3,1.3;2,1;close;"..S("Close").."]"..
"label[0.2,2.3;"..itext.."]"..
default.gui_bg..
default.gui_bg_img)
end
@ -170,10 +176,11 @@ pipeworks.register_tube("pipeworks:teleport_tube", {
on_construct = function(pos)
local meta = minetest.get_meta(pos)
update_meta(meta, true)
meta:set_string("infotext", S("unconfigured Teleportation Tube"))
meta:set_string("infotext", S("Unconfigured Teleportation Tube"))
end,
on_receive_fields = function(pos,formname,fields,sender)
if not fields.channel -- ignore escaping or clientside manipulation of the form
or (fields.quit and not fields.key_enter_field)
or not pipeworks.may_configure(pos, sender) then
return
end
@ -207,7 +214,7 @@ pipeworks.register_tube("pipeworks:teleport_tube", {
-- was the channel changed?
local channel = meta:get_string("channel")
if new_channel ~= channel then
if new_channel ~= channel and (fields.key_enter_field == "channel" or fields.set_channel) then
channel = new_channel
meta:set_string("channel", channel)
dirty = true
@ -233,7 +240,7 @@ pipeworks.register_tube("pipeworks:teleport_tube", {
else
-- remove empty channel tubes, to not have to search through them
remove_tube(pos)
meta:set_string("infotext", S("unconfigured Teleportation Tube"))
meta:set_string("infotext", S("Unconfigured Teleportation Tube"))
end
end
end,

View File

@ -113,6 +113,18 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1},
priority = 50
},
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)
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.break_tube(pos)
end
return minetest.node_punch(pos, node, player, pointed)
end,
after_place_node = pipeworks.after_place,
after_dig_node = pipeworks.after_dig,
on_rotate = false,

View File

@ -40,22 +40,31 @@ if pipeworks.enable_mese_sand_tube then
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_int("dist", 0)
meta:set_string("formspec", "size[2.1,0.8]"..
"image[0,0;1,1;pipeworks_mese_sand_tube_inv.png]"..
"field[1.3,0.4;1,1;dist;radius;${dist}]"..
meta:set_string("formspec",
"size[6.0,2.2]"..
"image[0.2,0;1,1;pipeworks_mese_sand_tube_inv.png]"..
"label[1.2,0.2;"..S("Adjustable Vacuuming Tube").."]"..
"field[0.5,1.6;2.1,1;dist;"..S("Radius")..";${dist}]"..
"button[2.3,1.3;1.5,1;set_dist;"..S("Set").."]"..
"button_exit[3.8,1.3;2,1;close;"..S("Close").."]"..
default.gui_bg..
default.gui_bg_img)
meta:set_string("infotext", S("Adjustable Vacuuming Pneumatic Tube Segment"))
end,
on_receive_fields = function(pos,formname,fields,sender)
if not pipeworks.may_configure(pos, sender) then return end
if (fields.quit and not fields.key_enter_field)
or (fields.key_enter_field ~= "dist" and not fields.set_dist)
or not pipeworks.may_configure(pos, sender) then
return
end
local meta = minetest.get_meta(pos)
local dist = tonumber(fields.dist)
if dist then
dist = math.max(0, dist)
dist = math.min(8, dist)
meta:set_int("dist", dist)
meta:set_string("infotext", (S("Adjustable Vacuuming Pneumatic Tube Segment (@1m)", dist)))
meta:set_string("infotext", S("Adjustable Vacuuming Pneumatic Tube Segment (@1m)", dist))
end
end,
},