mirror of
https://github.com/technix/ham_radio.git
synced 2024-11-30 10:53:46 +01:00
improve digiline
This commit is contained in:
parent
0c93918418
commit
652183d253
14
README.md
14
README.md
@ -18,6 +18,7 @@ Craft recipes depend of the mods installed.
|
||||
Craft a transmitter and place it in the world. Right click on transmitter to open configuration dialog, then set frequency and RDS message.
|
||||
- Empty frequency turns transmitter off.
|
||||
- Transmitter information is displayed as info text when player points at it.
|
||||
- RDS message can be multiline. However, it is transmitted line by line.
|
||||
- RDS message and frequency can be set via digiline. Also, you can read transmitter configuration via digiline too.
|
||||
|
||||
## Beacon
|
||||
@ -39,22 +40,25 @@ If RDS reception is toggled on, the RDS messages from all transmitters on this f
|
||||
## Stationary Receiver
|
||||
|
||||
Right click on receiver opens configuration window to set frequency. Receiver displays RDS messages as infotext in the same way as handheld receiver. It does not have signal power meter.
|
||||
- You can operate the receiver in the same way as the transmitter.
|
||||
|
||||
## Digiline
|
||||
|
||||
```lua
|
||||
-- this channel accepts plain text
|
||||
digiline.send('ham_radio_rds', 'new RDS message')
|
||||
-- channel "ham_radio_rds" accepts plain text
|
||||
digiline.send('ham_radio_rds', 'new RDS message')
|
||||
|
||||
-- get transmitter info
|
||||
digiline.send('ham_radio', { command = 'get' })
|
||||
-- returns { frequency = 12345, rds_message = 'text' }
|
||||
|
||||
-- set frequency
|
||||
digiline.send('ham_radio', { command = 'frequency', value = '12345' })
|
||||
digiline.send('ham_radio', { command = 'set_frequency', value = '12345' })
|
||||
-- returns { update = 'frequency', success = true/false, message = errorMessage }
|
||||
|
||||
-- set RDS message
|
||||
digiline.send('ham_radio', { command = 'rds_message', value = 'new RDS message' })
|
||||
digiline.send('ham_radio', { command = 'set_rds_message', value = 'new RDS message' })
|
||||
-- returns { update = 'rds_message', success = true }
|
||||
```
|
||||
|
||||
## What's next?
|
||||
@ -74,5 +78,3 @@ Source code: MIT
|
||||
Textures: CC BY-SA 3.0
|
||||
|
||||
Sounds: cut from "G32-20-Tuning Radio" by craigsmith, CC 0
|
||||
|
||||
|
||||
|
19
digiline.lua
19
digiline.lua
@ -25,23 +25,32 @@ ham_radio.digiline_effector = function(pos, _, channel, msg)
|
||||
end
|
||||
|
||||
if msg.command == "get" then
|
||||
digilines.receptor_send(pos, digilines.rules.default, digiline_channel, {
|
||||
digilines.receptor_send(pos, digilines.rules.default, command_channel, {
|
||||
frequency = meta:get_string("frequency"),
|
||||
rds_message = meta:get_string("rds_message"),
|
||||
})
|
||||
|
||||
elseif msg.command == "frequency" then
|
||||
elseif msg.command == "frequency" or msg.command == "set_frequency" then
|
||||
local new_frequency = msg.value
|
||||
if ham_radio.validate_frequency(new_frequency).result then
|
||||
local validate = ham_radio.validate_frequency(new_frequency)
|
||||
if validate.result then
|
||||
meta:set_string("frequency", new_frequency)
|
||||
ham_radio.transmitter_update_infotext(meta)
|
||||
ham_radio.save_transmitter(pos, meta)
|
||||
end
|
||||
digilines.receptor_send(pos, digilines.rules.default, command_channel, {
|
||||
update = 'frequency',
|
||||
success = validate.result,
|
||||
message = validate.message
|
||||
})
|
||||
|
||||
elseif msg.command == "rds" or msg.command == "message" or msg.command == "rds_message" then
|
||||
elseif msg.command == "rds" or msg.command == "message" or msg.command == "rds_message" or msg.command == "set_rds_message" then
|
||||
meta:set_string("rds_message", msg.value)
|
||||
ham_radio.transmitter_update_infotext(meta)
|
||||
ham_radio.save_transmitter(pos, meta)
|
||||
|
||||
digilines.receptor_send(pos, digilines.rules.default, command_channel, {
|
||||
update = 'rds_message',
|
||||
success = true
|
||||
})
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user