From e3d2d8fba9c0e925883ad5ce4d204f49b838ce0d Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Fri, 13 May 2022 12:48:03 +0200 Subject: [PATCH] Schema: Add enum support to settingtypes gen --- schema.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/schema.lua b/schema.lua index 6eaf531..5bfefb9 100644 --- a/schema.lua +++ b/schema.lua @@ -29,6 +29,20 @@ function generate_settingtypes(self) default = default and "true" or "false" elseif typ == "string" then settingtype = "string" + if self.values then + local values = {} + for value in pairs(self.values) do + if value:find"," then + values = nil + break + end + table.insert(values, value) + end + if values then + settingtype = "enum" + type_args = table.concat(values, ",") + end + end elseif typ == "number" then settingtype = self.int and "int" or "float" if self.range and (self.range.min or self.range.max) then