forked from mtcontrib/pipeworks
switch to the minetest-conventional def-table style of registering tubes to clean up their registrations
fallback for the old call is provided
This commit is contained in:
parent
810ae99008
commit
e60f86a588
@ -10,20 +10,20 @@ minetest.register_craft( {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if pipeworks.enable_accelerator_tube then
|
if pipeworks.enable_accelerator_tube then
|
||||||
local accelerator_noctr_textures = { "pipeworks_accelerator_tube_noctr.png" }
|
pipeworks.register_tube("pipeworks:accelerator_tube", {
|
||||||
local accelerator_plain_textures = { "pipeworks_accelerator_tube_plain.png" }
|
description = "Accelerating Pneumatic Tube Segment",
|
||||||
local accelerator_end_textures = { "pipeworks_accelerator_tube_end.png" }
|
inventory_image = "pipeworks_accelerator_tube_inv.png",
|
||||||
local accelerator_short_texture = "pipeworks_accelerator_tube_short.png"
|
plain = { "pipeworks_accelerator_tube_plain.png" },
|
||||||
local accelerator_inv_texture = "pipeworks_accelerator_tube_inv.png"
|
noctr = { "pipeworks_accelerator_tube_noctr.png" },
|
||||||
|
ends = { "pipeworks_accelerator_tube_end.png" },
|
||||||
pipeworks.register_tube("pipeworks:accelerator_tube", "Accelerating Pneumatic Tube Segment", accelerator_plain_textures,
|
short = "pipeworks_accelerator_tube_short.png",
|
||||||
accelerator_noctr_textures, accelerator_end_textures, accelerator_short_texture, accelerator_inv_texture,
|
node_def = {
|
||||||
{tube = {can_go = function(pos, node, velocity, stack)
|
tube = {can_go = function(pos, node, velocity, stack)
|
||||||
velocity.speed = velocity.speed+1
|
velocity.speed = velocity.speed+1
|
||||||
return pipeworks.notvel(pipeworks.meseadjlist, velocity)
|
return pipeworks.notvel(pipeworks.meseadjlist, velocity)
|
||||||
end}
|
end}
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft( {
|
minetest.register_craft( {
|
||||||
output = "pipeworks:accelerator_tube_1 2",
|
output = "pipeworks:accelerator_tube_1 2",
|
||||||
recipe = {
|
recipe = {
|
||||||
@ -32,23 +32,20 @@ if pipeworks.enable_accelerator_tube then
|
|||||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
|
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if pipeworks.enable_crossing_tube then
|
if pipeworks.enable_crossing_tube then
|
||||||
local crossing_noctr_textures = { "pipeworks_crossing_tube_noctr.png" }
|
pipeworks.register_tube("pipeworks:crossing_tube", {
|
||||||
local crossing_plain_textures = { "pipeworks_crossing_tube_plain.png" }
|
description = "Crossing Pneumatic Tube Segment",
|
||||||
local crossing_end_textures = { "pipeworks_crossing_tube_end.png" }
|
inventory_image = "pipeworks_crossing_tube_inv.png",
|
||||||
local crossing_short_texture = "pipeworks_crossing_tube_short.png"
|
plain = { "pipeworks_crossing_tube_plain.png" },
|
||||||
local crossing_inv_texture = "pipeworks_crossing_tube_inv.png"
|
noctr = { "pipeworks_crossing_tube_noctr.png" },
|
||||||
|
ends = { "pipeworks_crossing_tube_end.png" },
|
||||||
pipeworks.register_tube("pipeworks:crossing_tube", "Crossing Pneumatic Tube Segment", crossing_plain_textures,
|
short = "pipeworks_crossing_tube_short.png",
|
||||||
crossing_noctr_textures, crossing_end_textures, crossing_short_texture, crossing_inv_texture,
|
node_def = {
|
||||||
{tube = {can_go = function(pos, node, velocity, stack)
|
tube = {can_go = function(pos, node, velocity, stack) return {velocity} end }
|
||||||
return {velocity}
|
},
|
||||||
end}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft( {
|
minetest.register_craft( {
|
||||||
output = "pipeworks:crossing_tube_1 5",
|
output = "pipeworks:crossing_tube_1 5",
|
||||||
recipe = {
|
recipe = {
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
if pipeworks.enable_detector_tube then
|
if pipeworks.enable_detector_tube then
|
||||||
local detector_plain_textures = { "pipeworks_detector_tube_plain.png" }
|
|
||||||
local detector_inv_texture = "pipeworks_detector_tube_inv.png"
|
|
||||||
local detector_tube_step = 2 * tonumber(minetest.setting_get("dedicated_server_step"))
|
local detector_tube_step = 2 * tonumber(minetest.setting_get("dedicated_server_step"))
|
||||||
pipeworks.register_tube("pipeworks:detector_tube_on", "Detecting Pneumatic Tube Segment on (you hacker you)",
|
pipeworks.register_tube("pipeworks:detector_tube_on", {
|
||||||
detector_plain_textures, nil, nil, nil, detector_inv_texture,
|
description = "Detecting Pneumatic Tube Segment on (you hacker you)",
|
||||||
{tube = {can_go = function(pos, node, velocity, stack)
|
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 = minetest.get_meta(pos)
|
||||||
local name = minetest.get_node(pos).name
|
local name = minetest.get_node(pos).name
|
||||||
local nitems = meta:get_int("nitems")+1
|
local nitems = meta:get_int("nitems")+1
|
||||||
@ -15,8 +16,7 @@ if pipeworks.enable_detector_tube then
|
|||||||
end},
|
end},
|
||||||
groups = {mesecon = 2, not_in_creative_inventory = 1},
|
groups = {mesecon = 2, not_in_creative_inventory = 1},
|
||||||
drop = "pipeworks:detector_tube_off_1",
|
drop = "pipeworks:detector_tube_off_1",
|
||||||
mesecons = {receptor = {state = "on",
|
mesecons = {receptor = {state = "on", rules = pipeworks.mesecons_rules}},
|
||||||
rules = pipeworks.mesecons_rules}},
|
|
||||||
item_exit = function(pos)
|
item_exit = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local nitems = meta:get_int("nitems")-1
|
local nitems = meta:get_int("nitems")-1
|
||||||
@ -36,11 +36,15 @@ if pipeworks.enable_detector_tube then
|
|||||||
local name = minetest.get_node(pos).name
|
local name = minetest.get_node(pos).name
|
||||||
local saved_pos = vector.new(pos)
|
local saved_pos = vector.new(pos)
|
||||||
minetest.after(detector_tube_step, minetest.registered_nodes[name].item_exit, saved_pos)
|
minetest.after(detector_tube_step, minetest.registered_nodes[name].item_exit, saved_pos)
|
||||||
end
|
end,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
pipeworks.register_tube("pipeworks:detector_tube_off", "Detecting Pneumatic Tube Segment",
|
pipeworks.register_tube("pipeworks:detector_tube_off", {
|
||||||
detector_plain_textures, nil, nil, nil, detector_inv_texture,
|
description = "Detecting Pneumatic Tube Segment",
|
||||||
{tube = {can_go = function(pos, node, velocity, stack)
|
inventory_image = "pipeworks_detector_tube_inv.png",
|
||||||
|
plain = { "pipeworks_detector_tube_plain.png" },
|
||||||
|
node_def = {
|
||||||
|
tube = {can_go = function(pos, node, velocity, stack)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local name = node.name
|
local name = node.name
|
||||||
local fdir = node.param2
|
local fdir = node.param2
|
||||||
@ -48,9 +52,9 @@ if pipeworks.enable_detector_tube then
|
|||||||
mesecon.receptor_on(pos, pipeworks.mesecons_rules)
|
mesecon.receptor_on(pos, pipeworks.mesecons_rules)
|
||||||
return pipeworks.notvel(pipeworks.meseadjlist, velocity)
|
return pipeworks.notvel(pipeworks.meseadjlist, velocity)
|
||||||
end},
|
end},
|
||||||
groups = {mesecon = 2},
|
groups = {mesecon = 2},
|
||||||
mesecons = {receptor = {state = "off",
|
mesecons = {receptor = {state = "off", rules = pipeworks.mesecons_rules }},
|
||||||
rules = pipeworks.mesecons_rules}}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft( {
|
minetest.register_craft( {
|
||||||
@ -64,31 +68,34 @@ if pipeworks.enable_detector_tube then
|
|||||||
end
|
end
|
||||||
|
|
||||||
if pipeworks.enable_conductor_tube then
|
if pipeworks.enable_conductor_tube then
|
||||||
local conductor_plain_textures = { "pipeworks_conductor_tube_plain.png" }
|
pipeworks.register_tube("pipeworks:conductor_tube_off", {
|
||||||
local conductor_noctr_textures = { "pipeworks_conductor_tube_noctr.png" }
|
description = "Conducting Pneumatic Tube Segment",
|
||||||
local conductor_end_textures = { "pipeworks_conductor_tube_end.png" }
|
inventory_image = "pipeworks_conductor_tube_inv.png",
|
||||||
local conductor_short_texture = "pipeworks_conductor_tube_short.png"
|
short = "pipeworks_conductor_tube_short.png",
|
||||||
local conductor_inv_texture = "pipeworks_conductor_tube_inv.png"
|
plain = { "pipeworks_conductor_tube_plain.png" },
|
||||||
|
noctr = { "pipeworks_conductor_tube_noctr.png" },
|
||||||
local conductor_on_plain_textures = { "pipeworks_conductor_tube_on_plain.png" }
|
ends = { "pipeworks_conductor_tube_end.png" },
|
||||||
local conductor_on_noctr_textures = { "pipeworks_conductor_tube_on_noctr.png" }
|
node_def = {
|
||||||
local conductor_on_end_textures = { "pipeworks_conductor_tube_on_end.png" }
|
groups = {mesecon = 2},
|
||||||
|
mesecons = {conductor = {state = "off",
|
||||||
pipeworks.register_tube("pipeworks:conductor_tube_off", "Conducting Pneumatic Tube Segment", conductor_plain_textures, conductor_noctr_textures,
|
|
||||||
conductor_end_textures, conductor_short_texture, conductor_inv_texture,
|
|
||||||
{groups = {mesecon = 2},
|
|
||||||
mesecons = {conductor = {state = "off",
|
|
||||||
rules = pipeworks.mesecons_rules,
|
rules = pipeworks.mesecons_rules,
|
||||||
onstate = "pipeworks:conductor_tube_on_#id"}}
|
onstate = "pipeworks:conductor_tube_on_#id"}}
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
pipeworks.register_tube("pipeworks:conductor_tube_on", {
|
||||||
pipeworks.register_tube("pipeworks:conductor_tube_on", "Conducting Pneumatic Tube Segment on (you hacker you)", conductor_on_plain_textures, conductor_on_noctr_textures,
|
description = "Conducting Pneumatic Tube Segment on (you hacker you)",
|
||||||
conductor_on_end_textures, conductor_short_texture, conductor_inv_texture,
|
inventory_image = "pipeworks_conductor_tube_inv.png",
|
||||||
{groups = {mesecon = 2, not_in_creative_inventory = 1},
|
short = "pipeworks_conductor_tube_short.png",
|
||||||
drop = "pipeworks:conductor_tube_off_1",
|
plain_textures = { "pipeworks_conductor_tube_on_plain.png" },
|
||||||
mesecons = {conductor = {state = "on",
|
noctr = { "pipeworks_conductor_tube_on_noctr.png" },
|
||||||
|
ends = { "pipeworks_conductor_tube_on_end.png" },
|
||||||
|
node_def = {
|
||||||
|
groups = {mesecon = 2, not_in_creative_inventory = 1},
|
||||||
|
drop = "pipeworks:conductor_tube_off_1",
|
||||||
|
mesecons = {conductor = {state = "on",
|
||||||
rules = pipeworks.mesecons_rules,
|
rules = pipeworks.mesecons_rules,
|
||||||
offstate = "pipeworks:conductor_tube_off_#id"}}
|
offstate = "pipeworks:conductor_tube_off_#id"}}
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft( {
|
minetest.register_craft( {
|
||||||
|
@ -1,11 +1,4 @@
|
|||||||
if pipeworks.enable_mese_tube then
|
if pipeworks.enable_mese_tube then
|
||||||
local mese_noctr_textures = {"pipeworks_mese_tube_noctr_1.png", "pipeworks_mese_tube_noctr_2.png", "pipeworks_mese_tube_noctr_3.png",
|
|
||||||
"pipeworks_mese_tube_noctr_4.png", "pipeworks_mese_tube_noctr_5.png", "pipeworks_mese_tube_noctr_6.png"}
|
|
||||||
local mese_plain_textures = {"pipeworks_mese_tube_plain_1.png", "pipeworks_mese_tube_plain_2.png", "pipeworks_mese_tube_plain_3.png",
|
|
||||||
"pipeworks_mese_tube_plain_4.png", "pipeworks_mese_tube_plain_5.png", "pipeworks_mese_tube_plain_6.png"}
|
|
||||||
local mese_end_textures = { "pipeworks_mese_tube_end.png" }
|
|
||||||
local mese_short_texture = "pipeworks_mese_tube_short.png"
|
|
||||||
local mese_inv_texture = "pipeworks_mese_tube_inv.png"
|
|
||||||
local function update_formspec(pos)
|
local function update_formspec(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local old_formspec = meta:get_string("formspec")
|
local old_formspec = meta:get_string("formspec")
|
||||||
@ -40,9 +33,19 @@ if pipeworks.enable_mese_tube then
|
|||||||
buttons_formspec..
|
buttons_formspec..
|
||||||
"list[current_player;main;0,7;8,4;]")
|
"list[current_player;main;0,7;8,4;]")
|
||||||
end
|
end
|
||||||
pipeworks.register_tube("pipeworks:mese_tube", "Sorting Pneumatic Tube Segment", mese_plain_textures, mese_noctr_textures,
|
|
||||||
mese_end_textures, mese_short_texture, mese_inv_texture,
|
pipeworks.register_tube("pipeworks:mese_tube", {
|
||||||
{tube = {can_go = function(pos, node, velocity, stack)
|
description = "Sorting Pneumatic Tube Segment",
|
||||||
|
inventory_image = "pipeworks_mese_tube_inv.png",
|
||||||
|
noctr = {"pipeworks_mese_tube_noctr_1.png", "pipeworks_mese_tube_noctr_2.png", "pipeworks_mese_tube_noctr_3.png",
|
||||||
|
"pipeworks_mese_tube_noctr_4.png", "pipeworks_mese_tube_noctr_5.png", "pipeworks_mese_tube_noctr_6.png"},
|
||||||
|
plain = {"pipeworks_mese_tube_plain_1.png", "pipeworks_mese_tube_plain_2.png", "pipeworks_mese_tube_plain_3.png",
|
||||||
|
"pipeworks_mese_tube_plain_4.png", "pipeworks_mese_tube_plain_5.png", "pipeworks_mese_tube_plain_6.png"},
|
||||||
|
ends = { "pipeworks_mese_tube_end.png" },
|
||||||
|
short = "pipeworks_mese_tube_short.png",
|
||||||
|
no_facedir = true, -- Must use old tubes, since the textures are rotated with 6d ones
|
||||||
|
node_def = {
|
||||||
|
tube = {can_go = function(pos, node, velocity, stack)
|
||||||
local tbl, tbln = {}, 0
|
local tbl, tbln = {}, 0
|
||||||
local found, foundn = {}, 0
|
local found, foundn = {}, 0
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
@ -108,7 +111,8 @@ if pipeworks.enable_mese_tube then
|
|||||||
inv:set_stack(from_list, from_index, ItemStack(""))
|
inv:set_stack(from_list, from_index, ItemStack(""))
|
||||||
return 0
|
return 0
|
||||||
end,
|
end,
|
||||||
}, true) -- Must use old tubes, since the textures are rotated with 6d ones
|
},
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_craft( {
|
minetest.register_craft( {
|
||||||
output = "pipeworks:mese_tube_1 2",
|
output = "pipeworks:mese_tube_1 2",
|
||||||
|
@ -105,12 +105,6 @@ local function get_receivers(pos, channel)
|
|||||||
return receivers
|
return receivers
|
||||||
end
|
end
|
||||||
|
|
||||||
local teleport_noctr_textures={ "pipeworks_teleport_tube_noctr.png" }
|
|
||||||
local teleport_plain_textures={ "pipeworks_teleport_tube_plain.png" }
|
|
||||||
local teleport_end_textures={ "pipeworks_teleport_tube_end.png" }
|
|
||||||
local teleport_short_texture="pipeworks_teleport_tube_short.png"
|
|
||||||
local teleport_inv_texture="pipeworks_teleport_tube_inv.png"
|
|
||||||
|
|
||||||
local function update_meta(meta, can_receive)
|
local function update_meta(meta, can_receive)
|
||||||
meta:set_int("can_receive", can_receive and 1 or 0)
|
meta:set_int("can_receive", can_receive and 1 or 0)
|
||||||
local cr_state = can_receive and "on" or "off"
|
local cr_state = can_receive and "on" or "off"
|
||||||
@ -126,99 +120,105 @@ local function update_meta(meta, can_receive)
|
|||||||
default.gui_bg_img)
|
default.gui_bg_img)
|
||||||
end
|
end
|
||||||
|
|
||||||
pipeworks.register_tube("pipeworks:teleport_tube","Teleporting Pneumatic Tube Segment",teleport_plain_textures,
|
pipeworks.register_tube("pipeworks:teleport_tube", {
|
||||||
teleport_noctr_textures,teleport_end_textures,teleport_short_texture,teleport_inv_texture, {
|
description = "Teleporting Pneumatic Tube Segment",
|
||||||
is_teleport_tube = true,
|
inventory_image = "pipeworks_teleport_tube_inv.png",
|
||||||
tube = {
|
noctr = { "pipeworks_teleport_tube_noctr.png" },
|
||||||
can_go = function(pos,node,velocity,stack)
|
plain = { "pipeworks_teleport_tube_plain.png" },
|
||||||
velocity.x = 0
|
ends = { "pipeworks_teleport_tube_end.png" },
|
||||||
velocity.y = 0
|
short = "pipeworks_teleport_tube_short.png",
|
||||||
velocity.z = 0
|
node_def = {
|
||||||
|
is_teleport_tube = true,
|
||||||
|
tube = {
|
||||||
|
can_go = function(pos,node,velocity,stack)
|
||||||
|
velocity.x = 0
|
||||||
|
velocity.y = 0
|
||||||
|
velocity.z = 0
|
||||||
|
|
||||||
local channel = minetest.get_meta(pos):get_string("channel")
|
local channel = minetest.get_meta(pos):get_string("channel")
|
||||||
if channel == "" then return {} end
|
if channel == "" then return {} end
|
||||||
|
|
||||||
local target = get_receivers(pos, channel)
|
local target = get_receivers(pos, channel)
|
||||||
if target[1] == nil then return {} end
|
if target[1] == nil then return {} end
|
||||||
|
|
||||||
local d = math.random(1,#target)
|
local d = math.random(1,#target)
|
||||||
pos.x = target[d].x
|
pos.x = target[d].x
|
||||||
pos.y = target[d].y
|
pos.y = target[d].y
|
||||||
pos.z = target[d].z
|
pos.z = target[d].z
|
||||||
return pipeworks.meseadjlist
|
return pipeworks.meseadjlist
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
update_meta(meta, true)
|
update_meta(meta, true)
|
||||||
meta:set_string("infotext", "unconfigured Teleportation Tube")
|
meta:set_string("infotext", "unconfigured Teleportation Tube")
|
||||||
end,
|
end,
|
||||||
on_receive_fields = function(pos,formname,fields,sender)
|
on_receive_fields = function(pos,formname,fields,sender)
|
||||||
if not fields.channel then
|
if not fields.channel then
|
||||||
return -- ignore escaping or clientside manipulation of the form
|
return -- ignore escaping or clientside manipulation of the form
|
||||||
end
|
end
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local can_receive = meta:get_int("can_receive")
|
local can_receive = meta:get_int("can_receive")
|
||||||
|
|
||||||
-- check for private channels each time before actually changing anything
|
-- check for private channels each time before actually changing anything
|
||||||
-- to not even allow switching between can_receive states of private channels
|
-- to not even allow switching between can_receive states of private channels
|
||||||
if fields.channel ~= "" then
|
if fields.channel ~= "" then
|
||||||
local sender_name = sender:get_player_name()
|
local sender_name = sender:get_player_name()
|
||||||
local name, mode = fields.channel:match("^([^:;]+)([:;])")
|
local name, mode = fields.channel:match("^([^:;]+)([:;])")
|
||||||
if name and mode and name ~= sender_name then
|
if name and mode and name ~= sender_name then
|
||||||
--channels starting with '[name]:' can only be used by the named player
|
--channels starting with '[name]:' can only be used by the named player
|
||||||
if mode == ":" then
|
if mode == ":" then
|
||||||
minetest.chat_send_player(sender_name, "Sorry, channel '"..fields.channel.."' is reserved for exclusive use by "..name)
|
minetest.chat_send_player(sender_name, "Sorry, channel '"..fields.channel.."' is reserved for exclusive use by "..name)
|
||||||
return
|
return
|
||||||
|
|
||||||
--channels starting with '[name];' can be used by other players, but cannot be received from
|
--channels starting with '[name];' can be used by other players, but cannot be received from
|
||||||
elseif mode == ";" and (fields.cr1 or (can_receive ~= 0 and not fields.cr0)) then
|
elseif mode == ";" and (fields.cr1 or (can_receive ~= 0 and not fields.cr0)) then
|
||||||
minetest.chat_send_player(sender_name, "Sorry, receiving from channel '"..fields.channel.."' is reserved for "..name)
|
minetest.chat_send_player(sender_name, "Sorry, receiving from channel '"..fields.channel.."' is reserved for "..name)
|
||||||
return
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
local dirty = false
|
local dirty = false
|
||||||
|
|
||||||
-- was the channel changed?
|
-- was the channel changed?
|
||||||
local channel = meta:get_string("channel")
|
local channel = meta:get_string("channel")
|
||||||
if fields.channel ~= channel then
|
if fields.channel ~= channel then
|
||||||
channel = fields.channel
|
channel = fields.channel
|
||||||
meta:set_string("channel", channel)
|
meta:set_string("channel", channel)
|
||||||
dirty = true
|
dirty = true
|
||||||
end
|
|
||||||
|
|
||||||
-- test if a can_receive button was pressed
|
|
||||||
if fields.cr0 and can_receive ~= 0 then
|
|
||||||
can_receive = 0
|
|
||||||
update_meta(meta, false)
|
|
||||||
dirty = true
|
|
||||||
elseif fields.cr1 and can_receive ~= 1 then
|
|
||||||
can_receive = 1
|
|
||||||
update_meta(meta, true)
|
|
||||||
dirty = true
|
|
||||||
end
|
|
||||||
|
|
||||||
-- save if we changed something, handle the empty channel while we're at it
|
|
||||||
if dirty then
|
|
||||||
if channel ~= "" then
|
|
||||||
set_tube(pos, channel, can_receive)
|
|
||||||
local cr_description = (can_receive == 1) and "sending and receiving" or "sending"
|
|
||||||
meta:set_string("infotext", string.format("Teleportation Tube %s on '%s'", cr_description, channel))
|
|
||||||
else
|
|
||||||
-- remove empty channel tubes, to not have to search through them
|
|
||||||
remove_tube(pos)
|
|
||||||
meta:set_string("infotext", "unconfigured Teleportation Tube")
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end,
|
|
||||||
on_destruct = function(pos)
|
|
||||||
remove_tube(pos)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
|
-- test if a can_receive button was pressed
|
||||||
|
if fields.cr0 and can_receive ~= 0 then
|
||||||
|
can_receive = 0
|
||||||
|
update_meta(meta, false)
|
||||||
|
dirty = true
|
||||||
|
elseif fields.cr1 and can_receive ~= 1 then
|
||||||
|
can_receive = 1
|
||||||
|
update_meta(meta, true)
|
||||||
|
dirty = true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- save if we changed something, handle the empty channel while we're at it
|
||||||
|
if dirty then
|
||||||
|
if channel ~= "" then
|
||||||
|
set_tube(pos, channel, can_receive)
|
||||||
|
local cr_description = (can_receive == 1) and "sending and receiving" or "sending"
|
||||||
|
meta:set_string("infotext", string.format("Teleportation Tube %s on '%s'", cr_description, channel))
|
||||||
|
else
|
||||||
|
-- remove empty channel tubes, to not have to search through them
|
||||||
|
remove_tube(pos)
|
||||||
|
meta:set_string("infotext", "unconfigured Teleportation Tube")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_destruct = function(pos)
|
||||||
|
remove_tube(pos)
|
||||||
|
end
|
||||||
|
},
|
||||||
|
})
|
||||||
minetest.register_craft( {
|
minetest.register_craft( {
|
||||||
output = "pipeworks:teleport_tube_1 2",
|
output = "pipeworks:teleport_tube_1 2",
|
||||||
recipe = {
|
recipe = {
|
||||||
|
@ -147,7 +147,7 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
|
|||||||
minetest.register_node(rname, nodedef)
|
minetest.register_node(rname, nodedef)
|
||||||
end
|
end
|
||||||
|
|
||||||
pipeworks.register_tube = function(name, desc, plain, noctrs, ends, short, inv, special, old_registration)
|
local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv, special, old_registration)
|
||||||
if old_registration then
|
if old_registration then
|
||||||
for xm = 0, 1 do
|
for xm = 0, 1 do
|
||||||
for xp = 0, 1 do
|
for xp = 0, 1 do
|
||||||
@ -228,6 +228,20 @@ pipeworks.register_tube = function(name, desc, plain, noctrs, ends, short, inv,
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
pipeworks.register_tube = function(name, def, ...)
|
||||||
|
if type(def) == "table" then
|
||||||
|
register_all_tubes(name, def.description,
|
||||||
|
def.plain, def.noctr, def.ends, def.short,
|
||||||
|
def.inventory_image, def.node_def, def.no_facedir)
|
||||||
|
else
|
||||||
|
-- we assert to be the old function with the second parameter being the description
|
||||||
|
-- function(name, desc, plain, noctrs, ends, short, inv, special, old_registration)
|
||||||
|
assert(type(def) == "string", "invalid arguments to pipeworks.register_tube")
|
||||||
|
register_all_tubes(name, def, ...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
if REGISTER_COMPATIBILITY then
|
if REGISTER_COMPATIBILITY then
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"group:tube_to_update"},
|
nodenames = {"group:tube_to_update"},
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
if pipeworks.enable_sand_tube then
|
if pipeworks.enable_sand_tube then
|
||||||
local sand_noctr_textures = { "pipeworks_sand_tube_noctr.png" }
|
pipeworks.register_tube("pipeworks:sand_tube", {
|
||||||
local sand_plain_textures = { "pipeworks_sand_tube_plain.png" }
|
description = "Vacuuming Pneumatic Tube Segment",
|
||||||
local sand_end_textures = { "pipeworks_sand_tube_end.png" }
|
inventory_image = "pipeworks_sand_tube_inv.png",
|
||||||
local sand_short_texture = "pipeworks_sand_tube_short.png"
|
short = "pipeworks_sand_tube_short.png",
|
||||||
local sand_inv_texture = "pipeworks_sand_tube_inv.png"
|
noctr = { "pipeworks_sand_tube_noctr.png" },
|
||||||
|
plain = { "pipeworks_sand_tube_plain.png" },
|
||||||
pipeworks.register_tube("pipeworks:sand_tube", "Vacuuming Pneumatic Tube Segment", sand_plain_textures, sand_noctr_textures, sand_end_textures,
|
ends = { "pipeworks_sand_tube_end.png" },
|
||||||
sand_short_texture, sand_inv_texture,
|
node_def = { groups = {vacuum_tube = 1}},
|
||||||
{groups = {vacuum_tube = 1}})
|
})
|
||||||
|
|
||||||
minetest.register_craft( {
|
minetest.register_craft( {
|
||||||
output = "pipeworks:sand_tube_1 2",
|
output = "pipeworks:sand_tube_1 2",
|
||||||
@ -36,15 +36,15 @@ if pipeworks.enable_sand_tube then
|
|||||||
end
|
end
|
||||||
|
|
||||||
if pipeworks.enable_mese_sand_tube then
|
if pipeworks.enable_mese_sand_tube then
|
||||||
local mese_sand_noctr_textures = { "pipeworks_mese_sand_tube_noctr.png" }
|
pipeworks.register_tube("pipeworks:mese_sand_tube", {
|
||||||
local mese_sand_plain_textures = { "pipeworks_mese_sand_tube_plain.png" }
|
description = "Adjustable Vacuuming Pneumatic Tube Segment",
|
||||||
local mese_sand_end_textures = { "pipeworks_mese_sand_tube_end.png" }
|
inventory_image = "pipeworks_mese_sand_tube_inv.png",
|
||||||
local mese_sand_short_texture = "pipeworks_mese_sand_tube_short.png"
|
short = "pipeworks_mese_sand_tube_short.png",
|
||||||
local mese_sand_inv_texture = "pipeworks_mese_sand_tube_inv.png"
|
noctr = { "pipeworks_mese_sand_tube_noctr.png" },
|
||||||
|
plain = { "pipeworks_mese_sand_tube_plain.png" },
|
||||||
pipeworks.register_tube("pipeworks:mese_sand_tube", "Adjustable Vacuuming Pneumatic Tube Segment", mese_sand_plain_textures, mese_sand_noctr_textures,
|
ends = { "pipeworks_mese_sand_tube_end.png" },
|
||||||
mese_sand_end_textures, mese_sand_short_texture,mese_sand_inv_texture,
|
node_def = {
|
||||||
{groups = {vacuum_tube = 1},
|
groups = {vacuum_tube = 1},
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_int("dist", 0)
|
meta:set_int("dist", 0)
|
||||||
@ -63,6 +63,7 @@ if pipeworks.enable_mese_sand_tube then
|
|||||||
meta:set_string("infotext", ("Adjustable Vacuuming Pneumatic Tube Segment (%dm)"):format(dist))
|
meta:set_string("infotext", ("Adjustable Vacuuming Pneumatic Tube Segment (%dm)"):format(dist))
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft( {
|
minetest.register_craft( {
|
||||||
|
Loading…
Reference in New Issue
Block a user