From 28cce15aa3bd123e2875d4f76d2dbae7c4c3b233 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Sun, 12 Jun 2011 17:55:23 +0200 Subject: Lua resources: Add support for saving of boolean values --- src/FbTk/LResourceHelper.lua | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/FbTk/LResourceHelper.lua b/src/FbTk/LResourceHelper.lua index dd4ac2e..b16e756 100644 --- a/src/FbTk/LResourceHelper.lua +++ b/src/FbTk/LResourceHelper.lua @@ -102,11 +102,7 @@ local function register_resource(root, name, object) end; local function dump_(key, value, fd) - if type(value) == 'string' then - fd:write(key, ' = ', string.format('%q', value), '\n'); - elseif type(value) == 'number' then - fd:write(key, ' = ', string.format('%g', value), '\n'); - elseif type(value) == 'table' then + if type(value) == 'table' then fd:write(key, ' = {}\n'); for k, v in pairs(value) do k = append_name(key, k); @@ -124,7 +120,20 @@ local function dump_(key, value, fd) end; fd:write('\n'); else - error('Unsupported value type: ' .. type(val)); + if type(value) == 'string' then + value = string.format('%q', value); + elseif type(value) == 'number' then + value = string.format('%g', value); + elseif type(value) == 'boolean' then + if value then + value = "true"; + else + value = "false"; + end; + else + error('Unsupported value type for ' .. key .. ': ' .. type(value)); + end; + fd:write(key, ' = ', value, '\n'); end; end; -- cgit v0.11.2