mirror of
https://github.com/technix/ham_radio.git
synced 2025-01-24 04:51:25 +01:00
transmitter: better formspec validation
This commit is contained in:
parent
3a17c91da2
commit
42aed43d2d
@ -66,18 +66,29 @@ minetest.register_node("ham_radio:transmitter", {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local is_frequency_valid = ham_radio.validate_frequency(fields.frequency)
|
local meta = minetest.get_meta(pos)
|
||||||
if is_frequency_valid.result == false then
|
local transmitter_is_updated = false
|
||||||
ham_radio.errormsg(sender, is_frequency_valid.message)
|
|
||||||
return
|
if fields.frequency ~= nil then
|
||||||
|
local is_frequency_valid = ham_radio.validate_frequency(fields.frequency)
|
||||||
|
if is_frequency_valid.result == false then
|
||||||
|
ham_radio.errormsg(sender, is_frequency_valid.message)
|
||||||
|
else
|
||||||
|
meta:set_string("frequency", fields.frequency)
|
||||||
|
transmitter_is_updated = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
if fields.rds_message ~= nil then
|
||||||
meta:set_string("frequency", fields.frequency)
|
meta:set_string("rds_message", fields.rds_message)
|
||||||
meta:set_string("rds_message", fields.rds_message)
|
transmitter_is_updated = true
|
||||||
ham_radio.transmitter_update_infotext(meta)
|
end
|
||||||
ham_radio.save_transmitter(pos, meta)
|
|
||||||
ham_radio.play_tuning_sound(sender)
|
if transmitter_is_updated then
|
||||||
|
ham_radio.transmitter_update_infotext(meta)
|
||||||
|
ham_radio.save_transmitter(pos, meta)
|
||||||
|
ham_radio.play_tuning_sound(sender)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
local meta = minetest.get_meta(pos);
|
local meta = minetest.get_meta(pos);
|
||||||
|
Loading…
Reference in New Issue
Block a user