mirror of
https://github.com/joe7575/techpack.git
synced 2024-12-25 23:17:36 +01:00
Merge pull request #95 from oversword/issue-93
Provide default for all instances of retrieving a distributor filter
This commit is contained in:
commit
bc8ef5840b
@ -316,7 +316,7 @@ local function on_receive_fields(pos, formname, fields, player)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local meta = M(pos)
|
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
|
if fields.filter1 ~= nil then
|
||||||
filter[1] = fields.filter1 == "true"
|
filter[1] = fields.filter1 == "true"
|
||||||
elseif fields.filter2 ~= nil then
|
elseif fields.filter2 ~= nil then
|
||||||
@ -341,7 +341,7 @@ end
|
|||||||
local function change_filter_settings(pos, slot, val)
|
local function change_filter_settings(pos, slot, val)
|
||||||
local slots = {["red"] = 1, ["green"] = 2, ["blue"] = 3, ["yellow"] = 4}
|
local slots = {["red"] = 1, ["green"] = 2, ["blue"] = 3, ["yellow"] = 4}
|
||||||
local meta = M(pos)
|
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
|
local num = slots[slot] or 1
|
||||||
if num >= 1 and num <= 4 then
|
if num >= 1 and num <= 4 then
|
||||||
filter[num] = val == "on"
|
filter[num] = val == "on"
|
||||||
|
@ -285,7 +285,7 @@ local function on_receive_fields(pos, formname, fields, player)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local meta = M(pos)
|
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
|
if fields.filter1 ~= nil then
|
||||||
filter[1] = fields.filter1 == "true"
|
filter[1] = fields.filter1 == "true"
|
||||||
elseif fields.filter2 ~= nil then
|
elseif fields.filter2 ~= nil then
|
||||||
@ -310,7 +310,7 @@ end
|
|||||||
local function change_filter_settings(pos, slot, val)
|
local function change_filter_settings(pos, slot, val)
|
||||||
local slots = {["red"] = 1, ["green"] = 2, ["blue"] = 3, ["yellow"] = 4}
|
local slots = {["red"] = 1, ["green"] = 2, ["blue"] = 3, ["yellow"] = 4}
|
||||||
local meta = M(pos)
|
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
|
local num = slots[slot] or 1
|
||||||
if num >= 1 and num <= 4 then
|
if num >= 1 and num <= 4 then
|
||||||
filter[num] = val == "on"
|
filter[num] = val == "on"
|
||||||
|
Loading…
Reference in New Issue
Block a user