mirror of
https://github.com/joe7575/techpack.git
synced 2024-08-20 05:04:08 +02:00
Provide default for all instances of retrieving a distributor filter
This commit is contained in:
parent
4364f90e24
commit
f9026fa806
@ -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