summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--camera.lua1
-rw-r--r--cardreader.lua1
-rw-r--r--channelcopier.lua90
-rw-r--r--depends.txt1
-rw-r--r--detector.lua1
-rw-r--r--init.lua1
-rw-r--r--ioexpander.lua1
-rw-r--r--light.lua1
-rw-r--r--nic.lua1
-rw-r--r--noteblock.lua1
-rw-r--r--panel.lua5
-rw-r--r--piezo.lua1
-rw-r--r--piston.lua2
-rw-r--r--switches.lua7
-rw-r--r--textures/digistuff_channelcopier.pngbin0 -> 2428 bytes
-rw-r--r--timer.lua1
-rw-r--r--touchscreen.lua5
17 files changed, 120 insertions, 0 deletions
diff --git a/camera.lua b/camera.lua
index 3a2a129..e228790 100644
--- a/camera.lua
+++ b/camera.lua
@@ -11,6 +11,7 @@ minetest.register_node("digistuff:camera", {
{
receptor = {}
},
+ _digistuff_channelcopier_fieldname = "channel",
groups = {cracky=2},
paramtype = "light",
paramtype2 = "facedir",
diff --git a/cardreader.lua b/cardreader.lua
index 3279e90..2592d6d 100644
--- a/cardreader.lua
+++ b/cardreader.lua
@@ -58,6 +58,7 @@ minetest.register_node("digistuff:card_reader",{
local meta = minetest.get_meta(pos)
if fields.channel then meta:set_string("channel",fields.channel) end
end,
+ _digistuff_channelcopier_fieldname = "channel",
paramtype = "light",
paramtype2 = "facedir",
tiles = {
diff --git a/channelcopier.lua b/channelcopier.lua
new file mode 100644
index 0000000..7a86514
--- /dev/null
+++ b/channelcopier.lua
@@ -0,0 +1,90 @@
+minetest.register_tool("digistuff:channelcopier",{
+ description = "Digilines Channel Copier (shift-click to copy, click to paste)",
+ inventory_image = "digistuff_channelcopier.png",
+ on_use = function(itemstack,player,pointed)
+ if not (pointed and pointed.under) then return itemstack end
+ if not (player and player:get_player_name()) then return end
+ local pos = pointed.under
+ local name = player:get_player_name()
+ local node = minetest.get_node(pos)
+ if not node then return itemstack end
+ if minetest.registered_nodes[node.name]._digistuff_channelcopier_fieldname then
+ if player:get_player_control().sneak then
+ local channel = minetest.get_meta(pointed.under):get_string(minetest.registered_nodes[node.name]._digistuff_channelcopier_fieldname)
+ if type(channel) == "string" and channel ~= "" then
+ local stackmeta = itemstack:get_meta()
+ stackmeta:set_string("channel",channel)
+ stackmeta:set_string("description","Digilines Channel Copier, set to: "..channel)
+ if player and player:get_player_name() then minetest.chat_send_player(player:get_player_name(),"Digilines channel copier set to "..minetest.colorize("#00FFFF",channel)..". Click another node to paste this channel there.") end
+ end
+ else
+ if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then
+ minetest.record_protection_violation(pos,name)
+ return itemstack
+ end
+ if minetest.registered_nodes[node.name]._digistuff_channelcopier_fieldname then
+ local channel = itemstack:get_meta():get_string("channel")
+ if type(channel) ~= "string" or channel == "" then
+ minetest.chat_send_player(name,minetest.colorize("#FF5555","Error:").." No channel has been set yet. Shift-click to copy one.")
+ return itemstack
+ end
+ local oldchannel = minetest.get_meta(pos):get_string(minetest.registered_nodes[node.name]._digistuff_channelcopier_fieldname)
+ minetest.get_meta(pos):set_string(minetest.registered_nodes[node.name]._digistuff_channelcopier_fieldname,channel)
+ if type(oldchannel) == "string" and oldchannel ~= "" then
+ if channel == oldchannel then
+ minetest.chat_send_player(name,"Channel of target node is already "..minetest.colorize("#00FFFF",oldchannel)..".")
+ else
+ minetest.chat_send_player(name,string.format("Channel of target node changed from %s to %s.",minetest.colorize("#00FFFF",oldchannel),minetest.colorize("#00FFFF",channel)))
+ end
+ else
+ minetest.chat_send_player(name,"Channel of target node set to "..minetest.colorize("#00FFFF",channel)..".")
+ end
+ if type(minetest.registered_nodes[node.name]._digistuff_channelcopier_onset) == "function" then
+ minetest.registered_nodes[node.name]._digistuff_channelcopier_onset(pos,node,player,channel,oldchannel)
+ end
+ end
+ end
+ end
+ return itemstack
+ end,
+})
+
+minetest.register_craft({
+ output = "digistuff:channelcopier",
+ recipe = {
+ {"mesecons_fpga:programmer"},
+ {"digilines:wire_std_00000000"}
+ }
+})
+
+
+--NOTE: Asking to have your own mod added to here is not the right way to add compatibility with the channel copier.
+--Instead, include a _digistuff_channelcopier_fieldname field in your nodedef set to the name of the metadata field that contains the channel.
+--If you need an action to occur after the channel is set, place a function in _digistuff_channelcopier_onset.
+--Function signature is _digistuff_channelcopier_onset(pos,node,player,new_channel,old_channel)
+
+local additionalnodes = {
+ ["digilines:chest"] = "channel",
+ ["digilines:lcd"] = "channel",
+ ["digilines:lightsensor"] = "channel",
+ ["digilines:rtc"] = "channel",
+ ["pipeworks:digiline_detector_tube_1"] = "channel",
+ ["pipeworks:digiline_detector_tube_2"] = "channel",
+ ["pipeworks:digiline_detector_tube_3"] = "channel",
+ ["pipeworks:digiline_detector_tube_4"] = "channel",
+ ["pipeworks:digiline_detector_tube_5"] = "channel",
+ ["pipeworks:digiline_detector_tube_6"] = "channel",
+ ["pipeworks:digiline_detector_tube_7"] = "channel",
+ ["pipeworks:digiline_detector_tube_8"] = "channel",
+ ["pipeworks:digiline_detector_tube_9"] = "channel",
+ ["pipeworks:digiline_detector_tube_10"] = "channel",
+ ["pipeworks:digiline_filter"] = "channel",
+}
+
+for name,field in pairs(additionalnodes) do
+ if minetest.registered_nodes[name] and not minetest.registered_nodes[name]._digistuff_channelcopier_fieldname then
+ minetest.override_item(name,{_digistuff_channelcopier_fieldname = field})
+ end
+end
+
+
diff --git a/depends.txt b/depends.txt
index a3bfdda..5a8efa0 100644
--- a/depends.txt
+++ b/depends.txt
@@ -3,3 +3,4 @@ digilines
mesecons?
mesecons_mvps?
screwdriver?
+pipeworks?
diff --git a/detector.lua b/detector.lua
index f6542da..8cb4170 100644
--- a/detector.lua
+++ b/detector.lua
@@ -12,6 +12,7 @@ minetest.register_node("digistuff:detector", {
local meta = minetest.get_meta(pos)
meta:set_string("formspec","size[8,4;]field[1,1;6,2;channel;Channel;${channel}]field[1,2;6,2;radius;Radius;${radius}]button_exit[2.25,3;3,1;submit;Save]")
end,
+ _digistuff_channelcopier_fieldname = "channel",
on_receive_fields = function(pos, formname, fields, sender)
local name = sender:get_player_name()
if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then
diff --git a/init.lua b/init.lua
index bcc7b40..765ed74 100644
--- a/init.lua
+++ b/init.lua
@@ -14,6 +14,7 @@ local components = {
"piston",
"timer",
"cardreader",
+ "channelcopier",
}
if minetest.get_modpath("mesecons_luacontroller") then table.insert(components,"ioexpander") end
diff --git a/ioexpander.lua b/ioexpander.lua
index 1acfde7..59da390 100644
--- a/ioexpander.lua
+++ b/ioexpander.lua
@@ -118,6 +118,7 @@ for i=0,15,1 do
meta:set_int("don",0)
meta:set_int("outstate",i)
end,
+ _digistuff_channelcopier_fieldname = "channel",
tiles = gettiles(i),
inventory_image = "digistuff_ioexp_top.png",
drawtype = "nodebox",
diff --git a/light.lua b/light.lua
index aeca08d..ec9b6df 100644
--- a/light.lua
+++ b/light.lua
@@ -13,6 +13,7 @@ for i=0,14,1 do
{-0.25,0.4,-0.25,0.25,0.5,0.25},
}
},
+ _digistuff_channelcopier_fieldname = "channel",
groups = i > 0 and {cracky = 1, not_in_creative_inventory = 1} or {cracky = 1},
is_ground_content = false,
light_source = i,
diff --git a/nic.lua b/nic.lua
index 50bf105..03019fe 100644
--- a/nic.lua
+++ b/nic.lua
@@ -21,6 +21,7 @@ minetest.register_node("digistuff:nic", {
type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -5/16, 8/16 },
},
+ _digistuff_channelcopier_fieldname = "channel",
node_box = {
--From Luacontroller
type = "fixed",
diff --git a/noteblock.lua b/noteblock.lua
index 5bd0883..80c4936 100644
--- a/noteblock.lua
+++ b/noteblock.lua
@@ -21,6 +21,7 @@ minetest.register_node("digistuff:noteblock", {
tiles = {
"mesecons_noteblock.png"
},
+ _digistuff_channelcopier_fieldname = "channel",
on_receive_fields = function(pos, formname, fields, sender)
local name = sender:get_player_name()
if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then
diff --git a/panel.lua b/panel.lua
index d543af1..7ecc633 100644
--- a/panel.lua
+++ b/panel.lua
@@ -123,6 +123,11 @@ minetest.register_node("digistuff:panel", {
"digistuff_panel_back.png",
"digistuff_panel_front.png"
},
+ _digistuff_channelcopier_fieldname = "channel",
+ _digistuff_channelcopier_onset = function(pos)
+ local helpmsg = "Channel has been set. Waiting for data..."
+ digistuff.update_panel_formspec(pos,helpmsg)
+ end,
paramtype = "light",
paramtype2 = "facedir",
node_box = {
diff --git a/piezo.lua b/piezo.lua
index 39fce0d..3f040c8 100644
--- a/piezo.lua
+++ b/piezo.lua
@@ -14,6 +14,7 @@ minetest.register_node("digistuff:piezo", {
digistuff.sounds_playing[pos_hash] = nil
end
end,
+ _digistuff_channelcopier_fieldname = "channel",
tiles = {
"digistuff_piezo_top.png",
"digistuff_piezo_sides.png",
diff --git a/piston.lua b/piston.lua
index 070da43..bd8860b 100644
--- a/piston.lua
+++ b/piston.lua
@@ -66,6 +66,7 @@ minetest.register_node("digistuff:piston", {
local meta = minetest.get_meta(pos)
if fields.channel then meta:set_string("channel",fields.channel) end
end,
+ _digistuff_channelcopier_fieldname = "channel",
digiline = {
wire = {
rules = {
@@ -124,6 +125,7 @@ minetest.register_node("digistuff:piston_ext", {
{-0.5,-0.5,-1.5,0.5,0.5,0.5},
}
},
+ _digistuff_channelcopier_fieldname = "channel",
on_rotate = function() return false end,
on_receive_fields = function(pos, formname, fields, sender)
local name = sender:get_player_name()
diff --git a/switches.lua b/switches.lua
index 87d7a87..6f18432 100644
--- a/switches.lua
+++ b/switches.lua
@@ -95,6 +95,7 @@ minetest.register_node("digistuff:button", {
rules = digistuff.button_get_rules,
},
},
+ _digistuff_channelcopier_fieldname = "channel",
groups = {dig_immediate = 2,digiline_receiver = 1,},
description = "Digilines Button",
on_construct = function(pos)
@@ -160,6 +161,7 @@ minetest.register_node("digistuff:button_off", {
action = digistuff.button_handle_digilines,
},
},
+ _digistuff_channelcopier_fieldname = "channel",
groups = {dig_immediate = 2,not_in_creative_inventory = 1,digiline_receiver = 1,},
drop = "digistuff:button",
after_destruct = digistuff.remove_receiver,
@@ -204,6 +206,7 @@ minetest.register_node("digistuff:button_off_pushed", {
action = digistuff.button_handle_digilines,
},
},
+ _digistuff_channelcopier_fieldname = "channel",
on_timer = digistuff.button_turnoff,
groups = {dig_immediate = 2,not_in_creative_inventory = 1,digiline_receiver = 1,},
drop = "digistuff:button",
@@ -240,6 +243,7 @@ minetest.register_node("digistuff:button_on", {
{ -4/16, -2/16, 4/16, 4/16, 2/16, 6/16 } -- the button itself
}
},
+ _digistuff_channelcopier_fieldname = "channel",
digiline =
{
receptor = {},
@@ -279,6 +283,7 @@ minetest.register_node("digistuff:button_on_pushed", {
type = "fixed",
fixed = { -6/16, -6/16, 5/16, 6/16, 6/16, 8/16 }
},
+ _digistuff_channelcopier_fieldname = "channel",
node_box = {
type = "fixed",
fixed = {
@@ -338,6 +343,7 @@ minetest.register_node("digistuff:wall_knob", {
{-0.4,-0.4,0,0.4,0.4,0.5},
},
},
+ _digistuff_channelcopier_fieldname = "channel",
groups = {dig_immediate = 2,digiline_receiver = 1,},
description = "Digilines Wall Knob",
on_construct = function(pos)
@@ -397,6 +403,7 @@ minetest.register_node("digistuff:wall_knob_configured", {
{-0.4,-0.4,0,0.4,0.4,0.5},
},
},
+ _digistuff_channelcopier_fieldname = "channel",
groups = {dig_immediate = 2,digiline_receiver = 1,not_in_creative_inventory = 1,},
description = "Digilines Wall Knob (configured state - you hacker you!)",
drop = "digistuff:wall_knob",
diff --git a/textures/digistuff_channelcopier.png b/textures/digistuff_channelcopier.png
new file mode 100644
index 0000000..deb07e4
--- /dev/null
+++ b/textures/digistuff_channelcopier.png
Binary files differ
diff --git a/timer.lua b/timer.lua
index 4755564..fd624f2 100644
--- a/timer.lua
+++ b/timer.lua
@@ -29,6 +29,7 @@ minetest.register_node("digistuff:timer", {
{-3/16, -6/16, -3/16, 3/16, -5/16, 3/16}, -- IC
}
},
+ _digistuff_channelcopier_fieldname = "channel",
paramtype = "light",
sunlight_propagates = true,
on_receive_fields = function(pos, formname, fields, sender)
diff --git a/touchscreen.lua b/touchscreen.lua
index b0f10c2..e3255f2 100644
--- a/touchscreen.lua
+++ b/touchscreen.lua
@@ -290,6 +290,11 @@ minetest.register_node("digistuff:touchscreen", {
{ -0.5, -0.5, 0.4, 0.5, 0.5, 0.5 }
}
},
+ _digistuff_channelcopier_fieldname = "channel",
+ _digistuff_channelcopier_onset = function(pos)
+ minetest.get_meta(pos):set_int("init",1)
+ digistuff.update_ts_formspec(pos)
+ end,
on_receive_fields = digistuff.ts_on_receive_fields,
digiline =
{