Skip to content

Commit 9e83b06

Browse files
committed
Fix property when default value is false
1 parent 8bc7427 commit 9e83b06

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/cache_lua_libs.lua

+11
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,14 @@ local ERROR_PATH_LINE_MESSAGE_PATT = '"([^"]+)"[^:]*:(%d*):%s*(.*)'
6666
local function string_quote(s)
6767
return string_format('%q', s)
6868
end
69+
70+
local function first_index_not_nil(obj, ...)
71+
for i = 1, select('#', ...) do
72+
local index = select(i, ...)
73+
local value = obj[index]
74+
if value ~= nil then
75+
return value
76+
end
77+
end
78+
return nil
79+
end

src/pluginscript_class_metadata.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ function property(metadata)
224224
default_value = metadata
225225
property_type = get_property_type(metadata)
226226
else
227-
default_value = metadata.default_value or metadata.default or metadata[1]
227+
default_value = first_index_not_nil(metadata, 'default_value', 'default', 1)
228228
local explicit_type = metadata.type or metadata[2]
229229
if is_class_wrapper(explicit_type) then
230230
assert(explicit_type:inherits('Resource'), string_format("Only classes based on Resource are supported as property types, found %q", explicit_type.class_name))

0 commit comments

Comments
 (0)