mirror of
https://cheapiesystems.com/git/digistuff
synced 2024-11-28 10:03:49 +01:00
Add channel copier
This commit is contained in:
parent
69a9304751
commit
7f5eaac5c3
@ -11,6 +11,7 @@ minetest.register_node("digistuff:camera", {
|
||||
{
|
||||
receptor = {}
|
||||
},
|
||||
_digistuff_channelcopier_fieldname = "channel",
|
||||
groups = {cracky=2},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
|
@ -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 = {
|
||||
|
90
channelcopier.lua
Normal file
90
channelcopier.lua
Normal file
@ -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
|
||||
|
||||
|
@ -3,3 +3,4 @@ digilines
|
||||
mesecons?
|
||||
mesecons_mvps?
|
||||
screwdriver?
|
||||
pipeworks?
|
||||
|
@ -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
|
||||
|
1
init.lua
1
init.lua
@ -14,6 +14,7 @@ local components = {
|
||||
"piston",
|
||||
"timer",
|
||||
"cardreader",
|
||||
"channelcopier",
|
||||
}
|
||||
|
||||
if minetest.get_modpath("mesecons_luacontroller") then table.insert(components,"ioexpander") end
|
||||
|
@ -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",
|
||||
|
@ -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,
|
||||
|
1
nic.lua
1
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",
|
||||
|
@ -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
|
||||
|
@ -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 = {
|
||||
|
@ -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",
|
||||
|
@ -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()
|
||||
|
@ -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",
|
||||
|
BIN
textures/digistuff_channelcopier.png
Normal file
BIN
textures/digistuff_channelcopier.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
@ -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)
|
||||
|
@ -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 =
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user