From 843c68af145cd5a24eabc5ac89ecc81423ad3024 Mon Sep 17 00:00:00 2001 From: Jeija Date: Thu, 24 Apr 2014 10:59:16 +0200 Subject: [PATCH] Fix channel value getting deleted when quitting without editing the value in LCD, RTC and Light Sensor --- digilines_lcd/init.lua | 4 +++- digilines_lightsensor/init.lua | 6 +++--- digilines_rtc/init.lua | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/digilines_lcd/init.lua b/digilines_lcd/init.lua index fa02197..3d98e1c 100644 --- a/digilines_lcd/init.lua +++ b/digilines_lcd/init.lua @@ -105,7 +105,9 @@ minetest.register_node("digilines_lcd:lcd", { end, on_receive_fields = function(pos, formname, fields, sender) - minetest.get_meta(pos):set_string("channel", fields.channel) + if (fields.channel) then + minetest.get_meta(pos):set_string("channel", fields.channel) + end end, digiline = diff --git a/digilines_lightsensor/init.lua b/digilines_lightsensor/init.lua index 2bbbc27..7dda1ce 100644 --- a/digilines_lightsensor/init.lua +++ b/digilines_lightsensor/init.lua @@ -50,8 +50,8 @@ minetest.register_node("digilines_lightsensor:lightsensor", { meta:set_string("formspec", "field[channel;Channel;${channel}]") end, on_receive_fields = function(pos, formname, fields, sender) - local meta = minetest.get_meta(pos) - fields.channel = fields.channel or "" - meta:set_string("channel", fields.channel) + if (fields.channel) then + minetest.get_meta(pos):set_string("channel", fields.channel) + end end, }) diff --git a/digilines_rtc/init.lua b/digilines_rtc/init.lua index 40e84d0..6b7bfaf 100644 --- a/digilines_rtc/init.lua +++ b/digilines_rtc/init.lua @@ -46,8 +46,8 @@ minetest.register_node("digilines_rtc:rtc", { meta:set_string("formspec", "field[channel;Channel;${channel}]") end, on_receive_fields = function(pos, formname, fields, sender) - local meta = minetest.get_meta(pos) - fields.channel = fields.channel or "" - meta:set_string("channel", fields.channel) + if (fields.channel) then + minetest.get_meta(pos):set_string("channel", fields.channel) + end end, })