1-- This module reads a quest properties file with the format of Solarus 1.2 2-- (quest.dat) and converts it into the format of Solarus 1.3. 3 4-- The only difference is that the value of solarus_version changes. 5 6local converter = {} 7 8function converter.convert(quest_path) 9 10 local properties 11 12 -- Read the old file. 13 function quest(p) 14 15 if not p.solarus_version:match("^1.2%.?") then 16 error("This is not a Solarus 1.2 quest: the detected version is " .. p.solarus_version) 17 end 18 19 properties = p 20 end 21 22 dofile(quest_path .. "/data/quest.dat") 23 24 -- Write the new file. 25 local output_file = io.open(quest_path .. "/data/quest.dat", "w") 26 27 output_file:write("quest{\n") 28 output_file:write(" solarus_version = \"1.3\",\n") 29 if properties.write_dir ~= nil then 30 output_file:write(" write_dir = \"" .. properties.write_dir .. "\",\n") 31 end 32 if properties.title_bar ~= nil then 33 output_file:write(" title_bar = \"" .. properties.title_bar .. "\",\n") 34 end 35 if properties.normal_quest_size ~= nil then 36 output_file:write(" normal_quest_size = \"" .. properties.normal_quest_size .. "\",\n") 37 end 38 if properties.min_quest_size ~= nil then 39 output_file:write(" min_quest_size = \"" .. properties.min_quest_size .. "\",\n") 40 end 41 if properties.max_quest_size ~= nil then 42 output_file:write(" max_quest_size = \"" .. properties.max_quest_size .. "\",\n") 43 end 44 45 output_file:write("}\n\n"); 46 output_file:close() 47 48end 49 50return converter 51 52