-- -- Autor: Benjamín de la Fuente Ranea -- Fecha: 7-05-2009 -- -- Funciones de utilidad general -- -- Convierte un tiempo dado en segundos en una cadena de texto m‡s legible function ConvertTimeToString(_time) local minutosD = _time / 60 local minutos = math.floor(minutosD) local segundosD = _time - minutos * 60 local segundos = math.floor(segundosD) local milisegs = math.floor((_time - segundos) * 1000) if minutos == 0 then return segundos .. ":" .. milisegs else return minutos .. ":" .. segundos .. ":" .. milisegs end end -- Esta función revisa los datos de un parámetro de efecto -- y devuelve el número de keys que tiene y los nombres asociados function getEffectData(_param) local numKeys = 0 local keysMap = {} for k,v in pairs(_param) do numKeys = numKeys + 1 keysMap[numKeys] = k end return numKeys, keysMap end function table.val_to_str ( v ) if "string" == type( v ) then v = string.gsub( v, "\n", "\\n" ) if string.match( string.gsub(v,"[^'\"]",""), '^"+$' ) then return "'" .. v .. "'" end return '"' .. string.gsub(v,'"', '\\"' ) .. '"' else return "table" == type( v ) and table.tostring( v ) or tostring( v ) end end function table.key_to_str ( k ) if "string" == type( k ) and string.match( k, "^[_%a][_%a%d]*$" ) then return k else return "[" .. table.val_to_str( k ) .. "]" end end function table.tostring( tbl ) local result, done = {}, {} for k, v in ipairs( tbl ) do table.insert( result, table.val_to_str( v ) ) done[ k ] = true end for k, v in pairs( tbl ) do if not done[ k ] then table.insert( result, table.key_to_str( k ) .. "=" .. table.val_to_str( v ) ) end end return "{" .. table.concat( result, "," ) .. "}" end