fpga: Make formspec usage less prone to breakage

This commit is contained in:
sfan5 2017-01-28 11:54:27 +01:00
parent 07d074075c
commit 2bc3c5d97c

@ -142,7 +142,7 @@ plg.to_formspec_string = function(is)
local function dropdown_action(x, y, name, val) local function dropdown_action(x, y, name, val)
local s = "dropdown[" .. tostring(x) .. "," .. tostring(y) .. ";" local s = "dropdown[" .. tostring(x) .. "," .. tostring(y) .. ";"
.. "1.125,0.5;" .. name .. ";" -- the height seems to be ignored? .. "1.125,0.5;" .. name .. ";" -- the height seems to be ignored?
s = s .. " , AND, OR, NOT, XOR,NAND, =,XNOR;" s = s .. " , AND, OR, NOT, XOR,NAND, =,XNOR;"
if val == nil then if val == nil then
return s .. "0]" -- actually selects no field at all return s .. "0]" -- actually selects no field at all
end end
@ -203,14 +203,15 @@ plg.from_formspec_fields = function(fields)
return nil return nil
end end
local mapping = { local mapping = {
[" AND"] = "and", ["AND"] = "and",
[" OR"] = "or", ["OR"] = "or",
[" NOT"] = "not", ["NOT"] = "not",
[" XOR"] = "xor", ["XOR"] = "xor",
["NAND"] = "nand", ["NAND"] = "nand",
[" ="] = "buf", ["="] = "buf",
["XNOR"] = "xnor", ["XNOR"] = "xnor",
} }
s = s:gsub("^%s*", "") -- remove leading spaces
return mapping[s] return mapping[s]
end end
local is = {} local is = {}