foundryvtt-wh4-lang-fr-fr/tools/foundry_wh4_generic_merge.lua

30 lines
722 B
Lua
Raw Permalink Normal View History

2021-02-11 20:32:34 +01:00
package.path = package.path .. ";luajson/?.lua"
local JSON = require"json"
2021-12-23 10:13:10 +01:00
local oldf = "../compendium/wfrp4e-core.careers.json"
local newf = "../compendium/wfrp4e-core.career-descriptions.json"
2021-02-11 20:32:34 +01:00
2021-12-23 10:13:10 +01:00
local cf = io.open(oldf, "r")
local strjson = cf:read("*a")
cf:close()
local careers = JSON.decode(strjson)
2021-02-11 20:32:34 +01:00
2021-12-23 10:13:10 +01:00
local cdf = io.open(newf, "r")
strjson = cdf:read("*a")
cdf:close()
local careerDescr = JSON.decode(strjson)
2021-02-11 20:32:34 +01:00
2021-12-23 10:13:10 +01:00
for _, careerD in pairs(careerDescr.entries) do
for _, career in pairs(careers.entries) do
if careerD.id == career.id then
careerD.name = career.name
2021-02-11 20:32:34 +01:00
end
end
end
2021-12-23 10:13:10 +01:00
local jsonout = JSON.encode( careerDescr )
2021-02-11 20:32:34 +01:00
local fout = io.open("output.json", "w+")
fout:write( jsonout )
fout:close()