Skip to content

Commit 2bc3c5d

Browse files
committedJan 28, 2017
fpga: Make formspec usage less prone to breakage
1 parent 07d0740 commit 2bc3c5d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
 

Diff for: ‎mesecons_fpga/init.lua

+7-6
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ plg.to_formspec_string = function(is)
142142
local function dropdown_action(x, y, name, val)
143143
local s = "dropdown[" .. tostring(x) .. "," .. tostring(y) .. ";"
144144
.. "1.125,0.5;" .. name .. ";" -- the height seems to be ignored?
145-
s = s .. " , AND, OR, NOT, XOR,NAND, =,XNOR;"
145+
s = s .. " , AND, OR, NOT, XOR,NAND, =,XNOR;"
146146
if val == nil then
147147
return s .. "0]" -- actually selects no field at all
148148
end
@@ -203,14 +203,15 @@ plg.from_formspec_fields = function(fields)
203203
return nil
204204
end
205205
local mapping = {
206-
[" AND"] = "and",
207-
[" OR"] = "or",
208-
[" NOT"] = "not",
209-
[" XOR"] = "xor",
206+
["AND"] = "and",
207+
["OR"] = "or",
208+
["NOT"] = "not",
209+
["XOR"] = "xor",
210210
["NAND"] = "nand",
211-
[" ="] = "buf",
211+
["="] = "buf",
212212
["XNOR"] = "xnor",
213213
}
214+
s = s:gsub("^%s*", "") -- remove leading spaces
214215
return mapping[s]
215216
end
216217
local is = {}

0 commit comments

Comments
 (0)
Please sign in to comment.