Provide default for all instances of retrieving a distributor filter

This commit is contained in:
Oversword 2021-07-06 06:02:54 +01:00
parent 4364f90e24
commit f9026fa806
2 changed files with 4 additions and 4 deletions

@ -316,7 +316,7 @@ local function on_receive_fields(pos, formname, fields, player)
return
end
local meta = M(pos)
local filter = minetest.deserialize(meta:get_string("filter"))
local filter = minetest.deserialize(meta:get_string("filter")) or {false,false,false,false}
if fields.filter1 ~= nil then
filter[1] = fields.filter1 == "true"
elseif fields.filter2 ~= nil then
@ -341,7 +341,7 @@ end
local function change_filter_settings(pos, slot, val)
local slots = {["red"] = 1, ["green"] = 2, ["blue"] = 3, ["yellow"] = 4}
local meta = M(pos)
local filter = minetest.deserialize(meta:get_string("filter"))
local filter = minetest.deserialize(meta:get_string("filter")) or {false,false,false,false}
local num = slots[slot] or 1
if num >= 1 and num <= 4 then
filter[num] = val == "on"

@ -285,7 +285,7 @@ local function on_receive_fields(pos, formname, fields, player)
return
end
local meta = M(pos)
local filter = minetest.deserialize(meta:get_string("filter"))
local filter = minetest.deserialize(meta:get_string("filter")) or {false,false,false,false}
if fields.filter1 ~= nil then
filter[1] = fields.filter1 == "true"
elseif fields.filter2 ~= nil then
@ -310,7 +310,7 @@ end
local function change_filter_settings(pos, slot, val)
local slots = {["red"] = 1, ["green"] = 2, ["blue"] = 3, ["yellow"] = 4}
local meta = M(pos)
local filter = minetest.deserialize(meta:get_string("filter"))
local filter = minetest.deserialize(meta:get_string("filter")) or {false,false,false,false}
local num = slots[slot] or 1
if num >= 1 and num <= 4 then
filter[num] = val == "on"