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

52 lines
1.4 KiB
Lua
Raw Normal View History

2020-04-10 16:31:13 +02:00
package.path = package.path .. ";luajson/?.lua"
local JSON = require"json"
2021-02-06 21:50:08 +01:00
--local talent_db = "../../WFRP4e-FoundryVTT/packs/talents.db"
local talent_db ='/home/morr/.local/share/FoundryVTT/Data/modules/wfrp4e-core/packs/talents.db'
local talent = "../compendium/wfrp4e-core.talents.json"
2020-04-10 16:31:13 +02:00
local f1 = io.open(talent_db)
local f2 = io.open(talent)
local strjson = f2:read("*a")
f2:close()
local talents = JSON.decode(strjson)
local function trim1(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
end
local line = f1:read()
while line do
--print(line)
2021-02-06 21:50:08 +01:00
local db_talent = JSON.decode( line )
--print("Testing : ", db_talent.name )
for _, mytalent in pairs(talents.entries) do
if mytalent.id == db_talent.name then
mytalent.effects = {}
for i, effect in pairs(db_talent.effects) do
if effect.label == db_talent.name then
print("Found effect at : ", db_talent.name, mytalent.name, effect.label )
mytalent.effects['label'..i-1] = mytalent.name
elseif effect.label == 'Opposed Bonus' then
print("Test opposé !", effect.label)
mytalent.effects['label'..i-1] = 'Bonus au Tests Opposés'
else
mytalent.effects['label'..i-1] = effect.name
print("Unknow effect : ", effect.label)
end
end
2020-04-10 16:31:13 +02:00
end
end
2021-02-06 21:50:08 +01:00
2020-04-10 16:31:13 +02:00
line = f1:read()
end
f1:close()
2021-02-06 21:50:08 +01:00
2020-04-10 16:31:13 +02:00
local jsonout = JSON.encode( talents )
local fout = io.open("talents.json", "w+")
fout:write( jsonout )
fout:close()