digiline support

This commit is contained in:
techniX 2019-12-08 01:29:27 +02:00
parent 8c56210851
commit 9c9ec8ab4a
3 changed files with 41 additions and 2 deletions

30
digiline.lua Normal file

@ -0,0 +1,30 @@
ham_radio.digiline_effector = function(pos, _, channel, msg)
local digiline_channel = ham_radio.settings.digiline_channel -- static channel
if type(msg) ~= "table" or channel ~= digiline_channel then
return
end
local meta = minetest.get_meta(pos)
if msg.command == "get" then
digilines.receptor_send(pos, digilines.rules.default, digiline_channel, {
frequency = meta:get_string("frequency"),
broadcast_message = meta:get_string("broadcast_message"),
})
elseif msg.command == "frequency" then
local new_frequency = msg.value
if ham_radio.validate_frequency(new_frequency) then
meta:set_string("frequency", new_frequency)
ham_radio.transmitter_update_infotext(meta)
ham_radio.save_transmitter(pos, meta)
end
elseif msg.command == "broadcast" or msg.command == "message" or msg.command == "broadcast_message" then
meta:set_string("broadcast_message", msg.value)
ham_radio.transmitter_update_infotext(meta)
ham_radio.save_transmitter(pos, meta)
end
end

@ -15,7 +15,8 @@ ham_radio = {
frequency = {
min = 0,
max = 9999999
}
},
digiline_channel = "ham_radio",
}
}
@ -44,6 +45,7 @@ end
dofile(modpath.."/helpers.lua")
dofile(modpath.."/craft.lua")
dofile(modpath.."/digiline.lua")
dofile(modpath.."/transmitter.lua")
dofile(modpath.."/receiver.lua")
dofile(modpath.."/broadcast.lua")

@ -71,5 +71,12 @@ minetest.register_node("ham_radio:transmitter", {
end,
after_dig_node = function(pos, oldnode, oldmetadata, player)
ham_radio.delete_transmitter(pos)
end
end,
-- digiline
digiline = {
receptor = {action = function() end},
effector = {
action = ham_radio.digiline_effector
},
},
});