이거 문자 같은거 누락없이 디씨가 받아들여줄라나


----------------


/c

local copy = nil

copy = function(obj)

local t = type(obj)

local ret

if t == "table" then

ret = {}

for k, v in next, obj, nil do

ret[copy(k)] = copy(v)

end

else

ret = obj

end

return ret

end


local localising_table = {}


local localisation = function(obj)

if type(obj.localised_name) == "table" then

local id = #localising_table + 1

localising_table[id] = obj.localised_name

  return "@a@s@d@f@"..id.."@@@@@"

else

return obj.name

end

end


local function write_recipe(recipe)

return {

name = recipe.name,

localised_name = localisation(recipe),

category = recipe.category,

order = recipe.order,

group = recipe.group.name,

subgroup = recipe.subgroup.name,

main_product = assert(function()

if recipe.main_product then

local tbl = copy(recipe.main_product)

if game[tbl.type.."_prototypes"][tbl.name] then

tbl.name = localisation( game[tbl.type.."_prototypes"][tbl.name] )

end

return tbl

else

return "null"

end

end)(),

energy = recipe.energy,

ingredients = assert(function()

local tbl = copy(recipe.ingredients)

for i, v in ipairs(tbl) do

if game[v.type.."_prototypes"][v.name] then

tbl[i].name = localisation( game[v.type.."_prototypes"][v.name] )

end

end

return tbl

end)(),

products = assert(function()

local tbl = copy(recipe.products)

for i, v in ipairs(tbl) do

if game[v.type.."_prototypes"][v.name] then

tbl[i].name = localisation( game[v.type.."_prototypes"][v.name] )

end

end

return tbl

end)(),

}

end


local tbl = {}

for _, recipe in pairs(game.recipe_prototypes) do

table.insert( tbl, write_recipe(recipe) )

end

local str = game.table_to_json(tbl) .. "@a@s@d@f@ABCD@@@@@"

local fn = "recipes.json"

game.write_file( fn, '' )

for match1, match2 in str:gmatch("(.-)@a@s@d@f@(.-)@@@@@") do

game.write_file( fn, match1, true )

if match2 ~= "ABCD" then

game.write_file( fn, localising_table[match2 + 0], true )

end

end


---------------

콘솔창에 넣고 실행하면 레에에ㅔㅔㅔ엑 걸린 다음에 파일 만들어짐.