just a script for fixing broken familiar links between releases

This commit is contained in:
Enno Rehling 2015-09-15 17:43:22 +02:00
parent 1122bb70a4
commit a795226368
1 changed files with 30 additions and 0 deletions

30
scripts/fixfamiliars.lua Normal file
View File

@ -0,0 +1,30 @@
require 'config'
function write_fam(file)
for f in factions() do for u in f.units do if u.familiar then
file:write(u.id .. " " .. u.familiar.id .. "\n")
end end end
end
function read_fam(file)
m, f = file:read("*n", "*n")
while m and f do
mag = get_unit(m)
fam = get_unit(f)
if mag and fam then
mag.familiar = fam
end
m, f = file:read("*n", "*n")
end
end
eressea.read_game(get_turn()..".dat")
file = io.open("familiars.txt", "r")
if file then
read_fam(file)
eressea.write_game(get_turn()..".fix")
else
file = io.open("familiars.txt", "w")
write_fam(file)
end
file:close()