mirror of
https://github.com/technix/ham_radio.git
synced 2025-01-21 03:21:27 +01:00
digiline support
This commit is contained in:
parent
8c56210851
commit
9c9ec8ab4a
30
digiline.lua
Normal file
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
|
4
init.lua
4
init.lua
@ -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
|
||||
},
|
||||
},
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user