Merge pull request #95 from oversword/issue-93

Provide default for all instances of retrieving a distributor filter
This commit is contained in:
Joachim Stolberg 2021-07-06 18:37:39 +02:00 committed by GitHub
commit bc8ef5840b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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"